This article link: http://codingstandards.iteye.com/blog/842156 (reproduced please specify the source)
Description of Use
The Pstree command displays the relationship between processes in a tree view (display a tree of processes). The PS command can display information about those processes that are currently running, but the relationship between them is not clear enough. In a Linux system, the system calls fork to create sub-processes, through the child shell can also create sub-processes, Linux systems, the relationship between processes is a tree, the root of the tree is the process PID 1 of the Init process.
Common parameters
Format: Pstree
Displays the process in a tree view, showing only the name of the process, and the same process is displayed in the merge.
Format: pstree-p
Displays the process in a tree view, and also shows the process PID.
Format: Pstree <pid>
Format: Pstree-p <pid>
A tree view shows the process PID for the process of <pid> and descendant processes, and if there is a-p parameter, the PID of each process is displayed.
Format: pstree-a
The process is displayed in a tree view, processes with the same name are not merged, and command-line arguments are displayed, and if you have the-p parameter, the PID for each process is displayed.
Because the Pstree output may be more informative, it is best to work with more/less.
Using the example example one
[Email protected] ~]# Pstree
Init-+-acpid
|-atd
|-AUDITD-+-AUDISPD---{audispd}
| '-{AUDITD}
|-automount---4*[{automount}]
|-avahi-daemon---Avahi-daemon
|-crond---5*[crond-+-mj.sh]
| '-sendmail]
|-cupsd
|-dbus-daemon---{Dbus-daemon}
|-events/0
|-events/1
|-gam_server
|-gpm
|-hald---HALD-RUNNER-+-HALD-ADDON-ACPI
| |-hald-addon-keyb
| '-hald-addon-stor
|-hcid
|-hidd
|-hpiod
|-java-+-java---17*[{java}]
| ' -14*[{java}]
|-java-+-java---29*[{java}]
| ' -14*[{java}]
|-java-+-java---34*[{java}]
| ' -14*[{java}]
|-java---20*[{java}]
|-java---292*[{java}]
|-khelper
|-klogd
|-krfcommd
|-ksoftirqd/0
|-ksoftirqd/1
|-kthread-+-aio/0
| |-aio/1
| |-ata/0
| |-ata/1
| |-ata_aux
| |-cqueue/0
| |-cqueue/1
| |-hd-audio0
| |-kacpid
| |-kauditd
| |-kblockd/0
| |-kblockd/1
| |-khubd
| |-khungtaskd
| |-2*[kjournald]
| |-kmpath_handlerd
| |-kmpathd/0
| |-kmpathd/1
| |-kondemand/0
| |-kondemand/1
| |-kpsmoused
| |-kseriod
| |-ksnapd
| |-kstriped
| |-kswapd0
| |-2*[pdflush]
| |-rpciod/0
| |-rpciod/1
| |-scsi_eh_0
| |-scsi_eh_1
| |-scsi_eh_2
| |-scsi_eh_3
| |-scsi_eh_4
| '-scsi_eh_5
|-loop0
|-mcstransd
|-migration/0
|-migration/1
|-6*[mingetty]
|-MJ.SH---Make---java---11*[{java}]
|-ntpd
|-PCSCD---{PCSCD}
|-portmap
|-python
|-restorecond
|-rpc.idmapd
|-rpc.statd
|-screen---Bash---update.sh---CVS
|-sendmail---2*[sendmail]
|-sendmail
|-SETROUBLESHOOTD---2*[{SETROUBLESHOOTD}]
|-smartd
|-SSHD-+-SSHD---Bash---update_and_rest---CVS
| |-SSHD---Bash---pstree
| '-sshd---Bash
|-START_DERBY.SH---java---45*[{java}]
|-surf---8*[{surf}]
|-syslogd
|-tomcat---Sleep
|-udevd
|-watchdog/0
|-watchdog/1
|-xfs
|-xinetd
'-yum-updatesd
[Email protected] ~]#
Example Two
[Email protected] ~]# Pstree-p | Less
Init (1)-+-acpid (2569)
|-ATD (2983)
|-AUDITD (2225)-+-audispd (2227)---{audispd} (2232)
| '-{AUDITD} (2226)
|-automount (2654)-+-{automount} (2655)
| |-{automount} (2656)
| |-{automount} (2659)
| '-{automount} (2662)
|-avahi-daemon (3026)---avahi-daemon (3027)
|-crond (2916)-+-crond (14707)-+-mj.sh (14709)
| | '-sendmail (14773)
| |-crond (14708)-+-mj.sh (14710)
| | '-sendmail (14754)
| '-crond (26312)-+-mj.sh (26314)
| '-sendmail (26387)
|-CUPSD (2717)
|-dbus-daemon (2446)---{Dbus-daemon} (2447)
|-events/0 (8)
|-EVENTS/1 (9)
|-gam_server (3175)
|-GPM (2902)
|-hald (2587)---hald-runner (2588)-+-hald-addon-acpi (2596)
| |-hald-addon-keyb (13708)
| '-hald-addon-stor (2606)
|-hcid (2477)
|-hidd (2628)
|-hpiod (2676)
|-java (1572)-+-java (1586)-+-{java} (1590)
| | |-{java} (1591)
| | |-{java} (1592)
| | |-{java} (1593)
| | |-{java} (1594)
| | |-{java} (1595)
| | |-{java} (1596)
| | |-{java} (1597)
| | |-{java} (1598)
| | |-{java} (1599)
| | |-{java} (1600)
| | |-{java} (1782)
| | |-{java} (1783)
:
Example Three
[Email protected] ~]# Pstree-a | Less
Init
|-acpid
|-atd
|-auditd
| |-audispd
| | '-{AUDISPD}
| '-{AUDITD}
|-automount
| |-{automount}
| |-{automount}
| |-{automount}
| '-{automount}
|-avahi-daemon
| '-avahi-daemon
|-crond
| |-crond
| | |-(MJ.SH)
| | '-sendmail
| |-crond
| | |-(MJ.SH)
| | '-sendmail
| |-crond
| | |-(MJ.SH)
| | '-sendmail-fcrondaemon-i-odi-oem-oi-t
| |-crond
| | |-(MJ.SH)
| | '-sendmail-fcrondaemon-i-odi-oem-oi-t
| '-crond
| |-(MJ.SH)
| '-sendmail-fcrondaemon-i-odi-oem-oi-t
|-cupsd
|-dbus-daemon--system
| '-{dbus-daemon}
|-(events/0)
|-(EVENTS/1)
|-gam_server
|-gpm-m/dev/input/mice-t EXPS2
|-hald
| '-hald-runner
| |-hald-addon-acpi
:
Example Four
[Email protected] ~]# Pstree 2701
SSHD-+-SSHD---Bash---update_and_rest---CVS
|-SSHD---Bash---pstree
'-sshd---Bash
[Email protected] ~]# pstree-p 2701
SSHD (2701)-+-sshd (6745)---bash (6749)---update_and_rest (14193)---CVS (14194)
|-SSHD (12626)---bash (12630)---pstree (15588)
'-sshd (13324)---bash (13328)
[Email protected] ~]#
Pstree of Linux commands-show relationships between processes in a tree view