pstree - display a tree of processes

pstree  shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.

Without any argument

Without any argument, pstree prints out all the process in hierarchical structure

$ pstree
     │      └─sshd───bash───su───bash───pstree

Note:  pstree visually merges identical branches by putting them in square brackets and prefixing them with the repetition count, e.g.

  │   ├─{multipathd}
  │   ├─{multipathd}
  │   ├─{multipathd}
  │   ├─{multipathd}
  │   ├─{multipathd}
  │   └─{multipathd}



Print a PID process tree

$ pstree -a -p 2336
automount,2336 --pid-file /var/run/

Print a user's process tree

$ pstree mysql -a -p
mysqld,2567 --basedir=/usr --datadir=/data/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/

Highlight the current process and its ancestors

Very much like to print one PID's process tree, but this option not just print the process' subprocesses, it also prints out its ancestors and with highlight. Very useful option.


pstree -H 4121,-p -a
  │   ├─bash
  │   │   └─vi a
  │   │       └─bash
  │   │           └─pstree -H 4121,-p -a
  │   ├─gnome-pty-helpe
  │   └─3*[{gnome-terminal-}]

Full Syntax

More options to play with

Usage: pstree [ -a ] [ -c ] [ -h | -H PID ] [ -l ] [ -n ] [ -p ] [ -u ]
              [ -A | -G | -U ] [ PID | USER ]
       pstree -V
Display a tree of processes.

    -a     show command line arguments
    -A     use ASCII line drawing characters
    -c     don't compact identical subtrees
    -h     highlight current process and its ancestors
    -H PID highlight this process and its ancestors
    -G     use VT100 line drawing characters
    -l     don't truncate long lines
    -n     sort output by PID
    -p     show PIDs; implies -c
    -u     show uid transitions
    -U     use UTF-8 (Unicode) line drawing characters
    -V     display version information
    -Z     show SELinux security contexts
    PID    start at this PID; default is 1 (init)
    USER   show only trees rooted at processes of this user