Four super cool utilities that are part of the psmisc package

There are a ton of packages available for the various Linux distributions. Some of these packages aren’t as well know as others, though they contain some crazy awesome utilities. One package that fits into this cataegory is psmisc. Psmisc contains several tools that be used to print process statistics, look at file descriptor activity, see which process ids have a file or directory open, kill all processes that match a pattern and print the process table as a tree. Here is the list of utilities provided by psmisc:

$ rpm -q -l psmisc | grep bin


Starting at the top, the fuser tool will allow you to view the processes that have a file or directory open:

$ fuser -c -v /home/matty

/home/matty: root kernel mount /home
matty 1652 F.c.. sh
matty 1723 ....m imsettings-daem
matty 1810 F.c.m gnome-screensav
matty 1812 F.c.. xfce4-session
matty 1818 F.c.. xfsettingsd

Peekfd will display reads and writes to a set of file descriptors passed on the command line, or all of the file descriptors opened by a process:

$ peekfd 24983

reading fd 0:
writing fd 2:
reading fd 0:

writing fd 2:
[08] [1b] [K

Next up we have prtstat. This super handy tool will display the contents of /proc//stat in a nicely formatted ascii visual display:

$ prtstat 16860

Process: bash State: S (sleeping)
CPU#: 0 TTY: 136:1 Threads: 1
Process, Group and Session IDs
Process ID: 16860 Parent ID: 16855
Group ID: 16860 Session ID: 16860
T Group ID: 16860

Page Faults
This Process (minor major): 996 1
Child Processes (minor major): 6651 0
CPU Times
This Process (user system guest blkio): 0.00 0.01 0.00 0.00
Child processes (user system guest): 14.30 21.06 0.00
Vsize: 119 MB
RSS: 716 kB RSS Limit: 18446744073709 MB
Code Start: 0x400000 Code Stop: 0x4d8528
Stack Start: 0x7fff4b027150
Stack Pointer (ESP): 0x7fff4b025dd8 Inst Pointer (EIP): 0x3d0c0d3090
Policy: normal
Nice: 0 RT Priority: 0 (non RT)

And the last tool I love from this package is pstree. Pstree will print a tree-like structure of the process table, allowing you to easily see what started a given process:

$ pstree --ascii |more

| `-2*[{NetworkManager}]
| | `-pstree
| |-bash
| |-bash---ssh
| |-gnome-pty-helpe
| `-{Terminal}
| |-VirtualBox---22*[{VirtualBox}]
| |-2*[VirtualBox---21*[{VirtualBox}]]
| `-10*[{VBoxSVC}]

So there you go my friends, four amazing tools that don’t get the recognition they deserve. Which packages do you use that don’t get the street cred they deserve?

This article was posted by Matty on 2011-11-07 13:14:00 -0400 -0400