Monday, April 23, 2012

Show a hierarchy list of Linux processes

I just found a cool trick thanks to a colleague of mine David Saliba, to cleverly use the Linux ps tool to display a list of processes in a hierarchical order by using the fax flags (and it's easy to remember!):
[root@db10 ~]# ps fax | less
12778 ?        S      0:00 vncconfig -iconic
12779 ?        S      2:19 xterm -geometry 80x24+10+10 -ls db10:1
12782 pts/2    Ss+    0:00  \_ -bash
15101 pts/2    S     14:10      \_ xterm
15103 pts/3    Ss     0:00      |   \_ bash
15121 pts/3    S+   153:10      |       \_ top
15123 pts/2    S      2:01      \_ xterm
15125 pts/4    Ss     0:00          \_ bash
15143 pts/4    S+     1:12              \_ tail -f alert_dbp10.log
12780 ?        S      0:00 twm
32399 ?        S      1:31 xterm
32401 pts/5    Ss+    0:00  \_ bash
Also, if you pipe the command to less you can actually scroll sideways to see the whole command string if it does not fit completely in the screen.
[root@tst-str-dbp10 ~]# ps fax | less
Post a Comment