Linux

List processes in a hierarchy

ps -e -o pid,args –forest List processes by % cpu usage ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed ‘/^ 0.0 /d’ List processes by mem usage ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS List info for particular process IDs ps -p 1,2

Read More
Linux

Text manipulation using sed

Replace string1 with string2 sed ‘s/string1/string2/g’ Modify anystring1 to anystring2 sed ‘s/\(.*\)1/\12/g’ Remove comments and blank lines sed ‘/ *#/d; /^ *$/d’ Concatenate lines with trailing \ sed ‘:a; /\\$/N; s/\\\n//; ta’ Remove trailing spaces from lines sed ‘s/[ \t]*$//’ Escape shell metacharacters active within double quotes sed ‘s/\([\\`\\”$\\\\]\)/\\\1/g’ Print 1000th line sed -n ‘1000p;1000q’ […]

Read More
Linux

Synchronize current directory with remote one using rsync

This is a simple way to synchronize all the files from the current computer to a remote computer using SSH as transportation protocol. rsync -raz –progress –delete –bwlimit=4096 /synchronize/from/this-folder/ remote-server:/to/this-folder/ This example is using PUT as transfer method because the files are put from the local computer to the remote. Options explained -r synchronize directories […]

Read More