Friday, January 13, 2006

unix tip: ps - tree hierarchy view

linux ps command provides a nice process-tree hierarchy view when invoked with the -f or --forest option.
eg:

$ ps auxw --forest | less
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 3 0.0 0.0 0 0 ? SW 2005 0:00 [migration/1]
root 2 0.0 0.0 0 0 ? SW 2005 0:00 [migration/0]
root 1 0.0 0.0 1508 508 ? S 2005 0:38 init [3]
root 4 0.0 0.0 0 0 ? SW 2005 0:00 [keventd]
root 5 0.0 0.0 0 0 ? SWN 2005 0:00 [ksoftirqd/0]
root 6 0.0 0.0 0 0 ? SWN 2005 0:00 [ksoftirqd/1]
root 9 0.0 0.0 0 0 ? SW 2005 0:00 [bdflush]
root 7 0.0 0.0 0 0 ? SW 2005 0:30 [kswapd]
root 8 0.0 0.0 0 0 ? SW 2005 0:32 [kscand]
root 10 0.0 0.0 0 0 ? SW 2005 1:26 [kupdated]
root 11 0.0 0.0 0 0 ? SW 2005 0:00 [mdrecoveryd]
root 21 0.0 0.0 0 0 ? SW 2005 2:29 [kjournald]
root 86 0.0 0.0 0 0 ? SW 2005 0:00 [khubd]
root 3677 0.0 0.0 0 0 ? SW 2005 0:00 [kjournald]
root 3893 0.0 0.0 3972 1556 ? S 2005 0:29 /usr/sbin/sshd
root 25443 0.0 0.0 8744 3148 ? S 2005 0:00 \_ sshd: usercchx [priv]
usercchx 25529 0.0 0.0 8744 3360 ? S 2005 0:02 | \_ sshd: usercchx@pts/1
usercchx 25532 0.0 0.0 1812 728 pts/1 S 2005 0:00 | \_ -ksh
root 4540 0.0 0.0 8756 3184 ? S 2005 0:00 \_ sshd: userdju0 [priv]
userdju0 4648 0.0 0.0 8904 3484 ? S 2005 0:02 | \_ sshd: userdju0@pts/6
userdju0 4660 0.0 0.0 1808 716 pts/6 S 2005 0:00 | \_ -ksh
root 30124 0.0 0.0 8756 3184 ? S 2005 0:00 \_ sshd: userkyo1 [priv]
userkyo1 30321 0.0 0.0 8756 3404 ? S 2005 0:01 | \_ sshd: userkyo1@pts/12
userkyo1 30342 0.0 0.0 1808 700 pts/12 S 2005 0:00 | \_ -ksh
root 28994 0.0 0.0 8756 3160 ? S 2005 0:00 \_ sshd: user3 [priv]
user3 29237 0.0 0.0 8756 3376 ? S 2005 0:00 | \_ sshd: user3@pts/7
user3 29240 0.0 0.0 1804 696 pts/7 S 2005 0:00 | \_ -ksh
root 23316 0.0 0.0 8516 2500 ? S 2005 0:00 \_ sshd: root@pts/20
root 23322 0.0 0.0 4348 1348 pts/20 S 2005 0:00 | \_ -bash
root 13179 0.0 0.0 8676 2572 ? S 2005 0:00 \_ sshd: root@notty
root 7398 0.0 0.0 8748 3184 ? S 2005 0:00 \_ sshd: userdba5 [priv]
userdba5 7446 0.0 0.0 8896 3424 ? S 2005 0:01 | \_ sshd: userdba5@pts/28
userdba5 7454 0.0 0.0 1808 704 pts/28 S 2005 0:00 | \_ -ksh

or just use:
$ ps auxwf | less

but this option not available for other unix ps.

1 comment:

Anonymous said...

there is 1 command for tree view as well - pstree