Output Detailed Process Tree for any User

psu(){ command ps -Hcl -F S f -u ${1:-$USER}; }
An easy function to get a process tree listing (very detailed) for all the processes of any gived user. This function is also in my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Sample Output
$ psu askapache
F S     PID  PPID CLS PRI ADDR SZ WCHAN   RSS PSR TTY  CMD
5 S    4111  4099 TS   19 -  1790 poll_s 1556   0 ?     sshd: askapache@pts/0
0 S    4121  4111 TS   19 -   743 wait   1792   3 pts/0  \_ -bash
0 R   22083  4121 TS   19 -   641 -       824   0 pts/0     \_ ps -Hcl -F S f -u askapache

$ psu root
4 S       1     0 TS   19 -   486 poll_s  372   0 ?    init [2]
1 S    7007     1 TS   19 -   690 poll_s 1104   1 ?    /sbin/syslog-ng -p /var/run/syslog-ng.pid
5 S    7015     1 TS   19 -  1076 poll_s  852   0 ?    /usr/sbin/sshd
4 S    4099  7015 TS   19 -  1720 unix_s 2160   0 ?      \_ sshd: askapache [priv]
4 S   22256  7015 TS   19 -  1076 sk_wai 1848   1 ?      \_ sshd: [accepted]

What Others Think

Nice. Is this GNU/Linux specific?
hackerb9 · 464 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: