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]

These Might Interest You

  • Shows a less detailed output, made only of the process tree and their pids.


    1
    pstree -p
    Octave · 2009-08-20 23:31:30 0
  • whowatch is a interactive, ncurses-based, process and users monitoring tool, which updates information in real time. This is a perfect tool for local and remote servers. It displays information about the users currently logged on to the machine, in real-time. Besides standard information (login name, tty, host, user's process), the type of the connection (ie. telnet or ssh) is shown. Display of users command line can be switch to tty idle time. Certain user can be selected and his processes tree may be viewed as well as tree of all system processes. Tree may be displayed with additional column that shows owner of each process. In the process tree mode SIGINT and SIGKILL signals can be sent to the selected process. Killing processes is just as simple and fun as deleting lines on the screen.


    4
    whowatch
    cryptema · 2011-06-30 22:45:39 1
  • By 'pst' you can print out process tree with all details about all processes (including a command line, PID, and the current process you are running in). By 'pst username' you can get an information about processes belonging to the particular user 'username'. Show Sample Output


    0
    alias pst='pstree -Alpha'
    Alexander · 2009-03-20 10:53:37 0
  • Shows a tree view of parent to child processes in the output of ps (linux). Similar output can be achieved with pstree (also linux) or ptree (Solaris). Show Sample Output


    4
    ps auxf
    systemj · 2009-02-05 18:07:16 0

What Others Think

Nice. Is this GNU/Linux specific?
hackerb9 · 448 weeks 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: