Thursday, August 26, 2010

ps in linux

ps r: Shows only running processes.
ps f: Shows children descended from their parents in an ASCII art tree. I find this very useful when looking at problem processes. Use with the S option to see CPU information from children summed up with parents.

ps e: Shows the command environment for each process. This is useful in a situation where a program works for one user but not for another, or on one machine but not on another.
ps -t pts/3: Shows processes associated with the specified tty. I've found this useful when trying to work out who's doing what on a remote machine, and for how long.
ps u username: Generates much more readable and human friendly output.
ps -l username  : For long listing

Own output format
If you are bored by the regular output, you could simply change the format. To do so use the formatting characters which are supported by the ps command.
If you execute the ps command with the 'o' parameter you can tell the ps command what you want to see:
$ ps -o "%u : %U : %p : %a"
kinshukc : heyne    :  3363 : bash
kinshukc : heyne    :  3367 : ps -o %u : %U : %p : %a

for more do
$man ps



Post a Comment