pstree命令使用(转)

功能说明:以树状图显示程序。

  语  法:pstree [-acGhlnpuUV][-H <程序识别码>][<程序识别码>/<用户名称>]

  补充说明:pstree指令用ASCII字符显示树状结构,清楚地表达程序间的相互关系。如果不指定程序识别码或用户名称,则会把系统启动时的第一个程序视为基层,并显示之后的所有程序。若指定用户名称,便会以隶属该用户的第一个程序当作基层,然后显示该用户的所有程序。

  参  数:
  -a  显示每个程序的完整指令,包含路径,参数或是常驻服务的标示。
  -c  不使用精简标示法。
  -G  使用VT100终端机的列绘图字符。
  -h  列出树状图时,特别标明现在执行的程序。
  -H<程序识别码>  此参数的效果和指定"-h"参数类似,但特别标明指定的程序。
  -l  采用长列格式显示树状图。
  -n  用程序识别码排序。预设是以程序名称来排序。
  -p  显示程序识别码。
  -u  显示用户名称。
  -U  使用UTF-8列绘图字符。
  -V  显示版本信息。

再补充:

说明:将所有行程以树状图显示, 树状图将会以 pid (如果有指定) 或是以 init 这个基本行程为根 (root) ,如果有指定使用者 id , 则树状图会只显示该使用者所拥有的行程
参数:
-a 显示该行程的完整指令及参数, 如果是被记忆体置换出去的行程则会加上括号
-c 如果有重覆的行程名, 则分开列出 (预设值是会在前面加上 *)

示例:

1 使用pstree命令结果:

pstree

init-+-bscpserver
     |-crond
     |-dbproxy---2*[dbproxy]
     |-dbus-daemon-1
     |-events/0-+-aio/0
     |          |-aio/1
     |          |-aio/2
     |          |-aio/3
     |          |-aio/4
     |          |-aio/5
     |          |-aio/6
     |          |-aio/7
     |          |-ata/0
     |          |-ata/1
     |          |-ata/2
     |          |-ata/3
     |          |-ata/4
     |          |-ata/5
     |          |-ata/6
     |          |-ata/7
     |          |-kacpid
     |          |-kauditd
     |          |-kblockd/0
     |          |-kblockd/1
     |          |-kblockd/2
     |          |-kblockd/3
     |          |-kblockd/4
     |          |-kblockd/5
     |          |-kblockd/6
     |          |-kblockd/7
     |          |-khelper
     |          |-kmir_mon
     |          |-kmirrord
     |          `-2*[pdflush]
     |-events/1
     |-events/2
     |-events/3
     |-events/4
     |-events/5
     |-events/6
     |-events/7
     |-khubd
     |-klogd
     |-kseriod
     |-ksoftirqd/0
     |-ksoftirqd/1
     |-ksoftirqd/2
     |-ksoftirqd/3
     |-ksoftirqd/4
     |-ksoftirqd/5
     |-ksoftirqd/6
     |-ksoftirqd/7
     |-kswapd0
     |-2*[lighttpd-+-2*[cronolog]]
     |             `-5*[{lighttpd}]]
     |-migration/0
     |-migration/1
     |-migration/2
     |-migration/3
     |-migration/4
     |-migration/5
     |-migration/6
     |-migration/7
     |-6*[mingetty]
     |-mysqld_safe---mysqld---17*[{mysqld}]
     |-php---sh---php
     |-portmap
     |-6*[screen---bash]
     |-screen---bash---screen
     |-screen---2*[bash]
     |-shpchpd_event
     |-2*[ssh]
     |-sshd-+-sshd---sshd---bash---mysql
     |      |-3*[sshd---sshd---bash]
     |      |-2*[sshd---sshd---bash---bash---ssh]
     |      `-sshd---sshd---bash---pstree
     |-supervise---proftpd
     |-supervise.agent---noah-agent---noah-agent64-+-noah-agent64---27*[{noah-agent64}]
     |                                             `-supercpum64
     |-supervise.bscpl---bscplimitr
     |-supervise.drct---drct---27*[{drct}]
     |-supervise.ocage---open_vmstat
     |-supervise.ocage---open_iostat
     |-supervise.ocage---oc_python
     |-syslogd
     |-tinyproxy---79*[tinyproxy]
     |-udevd
     |-2*[vim]
     |-vmstat
     `-xinetd
2 使用pstree加p参数结果

pstree -p  
init(1)-+-bscpserver(27694)
        |-crond(2240)
        |-dbproxy(23477)-+-dbproxy(23481)
        |                `-dbproxy(23482)
        |-dbus-daemon-1(2249)
        |-events/0(18)-+-aio/0(116)
        |              |-aio/1(117)
        |              |-aio/2(118)
        |              |-aio/3(119)
        |              |-aio/4(120)
        |              |-aio/5(121)
        |              |-aio/6(122)
        |              |-aio/7(123)
        |              |-ata/0(275)
        |              |-ata/1(276)
        |              |-ata/2(277)
        |              |-ata/3(278)
        |              |-ata/4(279)
        |              |-ata/5(280)
        |              |-ata/6(281)
        |              |-ata/7(282)
        |              |-kacpid(27)
        |              |-kauditd(1632)
        |              |-kblockd/0(87)
        |              |-kblockd/1(88)
        |              |-kblockd/2(89)
        |              |-kblockd/3(90)
        |              |-kblockd/4(91)
        |              |-kblockd/5(92)
        |              |-kblockd/6(93)
        |              |-kblockd/7(94)
        |              |-khelper(26)
        |              |-kmir_mon(1845)
        |              |-kmirrord(1844)
        |              |-pdflush(19159)
        |              `-pdflush(4673)
        |-events/1(19)
        |-events/2(20)
        |-events/3(21)
        |-events/4(22)
        |-events/5(23)
        |-events/6(24)
        |-events/7(25)
        |-khubd(95)
        |-klogd(3897)
        |-kseriod(196)
        |-ksoftirqd/0(3)
        |-ksoftirqd/1(5)
        |-ksoftirqd/2(7)
        |-ksoftirqd/3(9)
        |-ksoftirqd/4(11)
        |-ksoftirqd/5(13)
        |-ksoftirqd/6(15)
        |-ksoftirqd/7(17)
        |-kswapd0(115)
        |-lighttpd(17792)-+-cronolog(17793)
        |                 |-cronolog(17794)
        |                 |-{lighttpd}(17795)
        |                 |-{lighttpd}(17796)
        |                 |-{lighttpd}(17797)
        |                 |-{lighttpd}(17798)
        |                 `-{lighttpd}(17799)
        |-lighttpd(5265)-+-cronolog(5274)
        |                |-cronolog(5275)
        |                |-{lighttpd}(5276)
        |                |-{lighttpd}(5277)
        |                |-{lighttpd}(5278)
        |                |-{lighttpd}(5279)
        |                `-{lighttpd}(5280)
        |-migration/0(2)
        |-migration/1(4)
        |-migration/2(6)
        |-migration/3(8)
        |-migration/4(10)
        |-migration/5(12)
        |-migration/6(14)
        |-migration/7(16)
        |-mingetty(3905)
        |-mingetty(3907)
        |-mingetty(3908)
        |-mingetty(3909)
        |-mingetty(3910)
        |-mingetty(3911)
        |-mysqld_safe(6146)---mysqld(6331)-+-{mysqld}(6335)
        |                                  |-{mysqld}(6336)
        |                                  |-{mysqld}(6337)
        |                                  |-{mysqld}(6338)
        |                                  |-{mysqld}(6357)
        |                                  |-{mysqld}(6358)
        |                                  |-{mysqld}(6359)
        |                                  |-{mysqld}(6360)
        |                                  |-{mysqld}(18770)
        |                                  |-{mysqld}(19006)
        |                                  |-{mysqld}(20000)
        |                                  |-{mysqld}(20004)
        |                                  |-{mysqld}(31148)
        |                                  |-{mysqld}(21640)
        |                                  |-{mysqld}(15041)
        |                                  |-{mysqld}(8296)
        |                                  `-{mysqld}(29276)
        |-php(28092)---sh(12817)---php(12818)
        |-portmap(2208)
        |-screen(32465)---bash(1102)
        |-screen(7952)---bash(7953)---screen(7997)
        |-screen(8017)-+-bash(8018)
        |              `-bash(8093)
        |-screen(21321)---bash(21325)
        |-screen(31402)---bash(31405)
        |-screen(32160)---bash(32161)
        |-screen(6035)---bash(6041)
        |-screen(11736)---bash(11739)
        |-shpchpd_event(1241)
        |-ssh(10595)
        |-ssh(30680)
        |-sshd(2219)-+-sshd(21051)---sshd(21055)---bash(21056)---mysql(21090)
        |            |-sshd(5440)---sshd(5444)---bash(5445)
        |            |-sshd(6838)---sshd(6842)---bash(6843)---bash(6895)---ssh(6897)
        |            |-sshd(23939)---sshd(23943)---bash(23944)
        |            |-sshd(15181)---sshd(15187)---bash(15188)
        |            |-sshd(15719)---sshd(15723)---bash(15724)---bash(31820)---ssh(31822)
        |            `-sshd(13178)---sshd(13182)---bash(13183)---pstree(13625)
        |-supervise(2256)---proftpd(2322)
        |-supervise.agent(21285)---noah-agent(2035)---noah-agent64(2039)-+-noah-agent64(2040)-+-{noah-agent64}(2098)
        |                                                                |                    |-{noah-agent64}(2099)
        |                                                                |                    |-{noah-agent64}(2100)
        |                                                                |                    |-{noah-agent64}(2101)
        |                                                                |                    |-{noah-agent64}(2102)
        |                                                                |                    |-{noah-agent64}(2103)
        |                                                                |                    |-{noah-agent64}(2104)
        |                                                                |                    |-{noah-agent64}(2105)
        |                                                                |                    |-{noah-agent64}(2106)
        |                                                                |                    |-{noah-agent64}(2107)
        |                                                                |                    |-{noah-agent64}(2108)
        |                                                                |                    |-{noah-agent64}(2109)
        |                                                                |                    |-{noah-agent64}(2110)
        |                                                                |                    |-{noah-agent64}(2111)
        |                                                                |                    |-{noah-agent64}(2112)
        |                                                                |                    |-{noah-agent64}(2113)
        |                                                                |                    |-{noah-agent64}(2114)
        |                                                                |                    |-{noah-agent64}(2115)
        |                                                                |                    |-{noah-agent64}(2116)
        |                                                                |                    |-{noah-agent64}(2117)
        |                                                                |                    |-{noah-agent64}(2118)
        |                                                                |                    |-{noah-agent64}(2119)
        |                                                                |                    |-{noah-agent64}(2120)
        |                                                                |                    |-{noah-agent64}(2121)
        |                                                                |                    |-{noah-agent64}(2122)
        |                                                                |                    |-{noah-agent64}(2123)
        |                                                                |                    `-{noah-agent64}(2124)
        |                                                                `-supercpum64(2041)
        |-supervise.bscpl(23811)---bscplimitr(23812)
        |-supervise.drct(4557)---drct(21674)-+-{drct}(21679)
        |                                    |-{drct}(21680)
        |                                    |-{drct}(21681)
        |                                    |-{drct}(21682)
        |                                    |-{drct}(21683)
        |                                    |-{drct}(21684)
        |                                    |-{drct}(21685)
        |                                    |-{drct}(21686)
        |                                    |-{drct}(21687)
        |                                    |-{drct}(21688)
        |                                    |-{drct}(21689)
        |                                    |-{drct}(21690)
        |                                    |-{drct}(21691)
        |                                    |-{drct}(21692)
        |                                    |-{drct}(21693)
        |                                    |-{drct}(21694)
        |                                    |-{drct}(21695)
        |                                    |-{drct}(21696)
        |                                    |-{drct}(21697)
        |                                    |-{drct}(21698)
        |                                    |-{drct}(21699)
        |                                    |-{drct}(21700)
        |                                    |-{drct}(21701)
        |                                    |-{drct}(21702)
        |                                    |-{drct}(21703)
        |                                    |-{drct}(21704)
        |                                    `-{drct}(21705)
        |-supervise.ocage(21247)---open_vmstat(21251)
        |-supervise.ocage(21248)---open_iostat(21252)
        |-supervise.ocage(21265)---oc_python(21267)
        |-syslogd(3893)
        |-tinyproxy(4559)-+-tinyproxy(4567)
        |                 |-tinyproxy(4568)
        |                 |-tinyproxy(4570)
        |                 |-tinyproxy(4572)
        |                 |-tinyproxy(4573)
        |                 |-tinyproxy(4575)
        |                 |-tinyproxy(11283)
        |                 |-tinyproxy(26508)
        |                 |-tinyproxy(6037)
        |                 |-tinyproxy(6038)
        |                 |-tinyproxy(6098)
        |                 |-tinyproxy(22394)
        |                 |-tinyproxy(2605)
        |                 |-tinyproxy(3402)
        |                 |-tinyproxy(10781)
        |                 |-tinyproxy(10824)
        |                 |-tinyproxy(10834)
        |                 |-tinyproxy(11925)
        |                 |-tinyproxy(12358)
        |                 |-tinyproxy(13114)
        |                 |-tinyproxy(12765)
        |                 |-tinyproxy(12778)
        |                 |-tinyproxy(12779)
        |                 |-tinyproxy(12788)
        |                 |-tinyproxy(12789)
        |                 |-tinyproxy(12802)
        |                 |-tinyproxy(12803)
        |                 |-tinyproxy(12812)
        |                 |-tinyproxy(12823)
        |                 |-tinyproxy(12836)
        |                 |-tinyproxy(12837)
        |                 |-tinyproxy(12846)
        |                 |-tinyproxy(12847)
        |                 |-tinyproxy(12860)
        |                 |-tinyproxy(12861)
        |                 |-tinyproxy(12870)
        |                 |-tinyproxy(9971)
        |                 |-tinyproxy(21108)
        |                 |-tinyproxy(17210)
        |                 |-tinyproxy(29420)
        |                 |-tinyproxy(2929)
        |                 |-tinyproxy(583)
        |                 |-tinyproxy(592)
        |                 |-tinyproxy(610)
        |                 |-tinyproxy(619)
        |                 |-tinyproxy(620)
        |                 |-tinyproxy(634)
        |                 |-tinyproxy(643)
        |                 |-tinyproxy(644)
        |                 |-tinyproxy(653)
        |                 |-tinyproxy(658)
        |                 |-tinyproxy(667)
        |                 |-tinyproxy(668)
        |                 |-tinyproxy(677)
        |                 |-tinyproxy(700)
        |                 |-tinyproxy(11924)
        |                 |-tinyproxy(11930)
        |                 |-tinyproxy(11939)
        |                 |-tinyproxy(12212)
        |                 |-tinyproxy(12217)
        |                 |-tinyproxy(12227)
        |                 |-tinyproxy(12236)
        |                 |-tinyproxy(12241)
        |                 |-tinyproxy(12260)
        |                 |-tinyproxy(12281)
        |                 |-tinyproxy(15618)
        |                 |-tinyproxy(2575)
        |                 |-tinyproxy(8055)
        |                 |-tinyproxy(26794)
        |                 |-tinyproxy(889)
        |                 |-tinyproxy(12675)
        |                 |-tinyproxy(12676)
        |                 |-tinyproxy(12685)
        |                 |-tinyproxy(12686)
        |                 |-tinyproxy(12699)
        |                 |-tinyproxy(12700)
        |                 |-tinyproxy(12709)
        |                 |-tinyproxy(12710)
        |                 `-tinyproxy(12741)
        |-udevd(1281)
        |-vim(16605)
        |-vim(16766)
        |-vmstat(6129)
        `-xinetd(1070)

你可能感兴趣的:(pstree命令使用(转))