Linux pstree command
The Linux pstree (display a tree of processes) command displays all processes as a tree diagram. The tree is rooted at the pid (if specified) or at the basic init process. If a user id is specified, the tree will show only the processes owned by that user.
Permissions required: all users.
Syntax
pstree [-a] [-c] [-h|-Hpid] [-l] [-n] [-p] [-u] [-G|-U] [pid|user]
or
pstree -V
Parameter Description:
- -a Displays the full command and arguments of the process; if the process has been swapped out of memory, it is shown in parentheses
- -c If there are duplicate process names, list them separately (by default a * is added in front)
Example
Display process relationships
pstree
init-+-amd
|-apmd
|-atd
|-httpd---10*[httpd]
%pstree -p
init(1)-+-amd(447)
|-apmd(105)
|-atd(339)
%pstree -c
init-+-amd
|-apmd
|-atd
|-httpd-+-httpd
| |-httpd
| |-httpd
| |-httpd
....
Specially mark running processes
# pstree -apnh //显示进程间的关系
Also display the user name
# pstree -u //显示用户名称
Linux Command Reference