[plug] Useful command - pstree

Peter Wright pete at cygnus.uwa.edu.au
Thu Apr 19 15:57:40 WST 2001


I just thought some of you might be interested to know about the pstree
command (which I think I'd heard about before, but had never actually used).

Just to explain a bit - I've been using ps with a particular set of flags
('aux' or a subset thereof) for so long that the sequence has become almost
hardwired into my brain. Recently, I've been interested in finding out the
parent process id (PPID) of a particular process - but 'ps axu' doesn't
show the PPID. If you're interested, 'ps axl' will do it.

Anyway, while I was practising curbing my instinct to type 'axu' and use
'axl' instead, I was thinking that it's visually not too easy to work out
exactly _what_ the parent process is - there's a couple of steps that you
need to go through (run ps, find the PID of the process you want, find the
PPID of that process, then work out what process that is). I thought "damn,
there really should be a way to display the process table as a tree... hang
on a second..."

Of course, pstree turned out to be exactly what I wanted. Anyway, I read
the man page to find out all the useful parameters and work out my
"default" parameters (much as 'aux' is my default for ps). I eventually
found I liked:

-G	Use VT100 line drawing characters (looks much nicer).
-l	Display long lines (will wrap on narrow terminals though).
-p	Show process IDs.
-u	Show user id changes (ie. whenever the uid of a process changes
	from the uid of its parent).

Hence, my preferred call format (coincidentally quite easy to remember):

$ pstree -pluG

:)

Pete.
-- 
http://cygnus.uwa.edu.au/~pete/

--
hundred-and-one symptoms of being an internet addict:
107. When using your phone you forget that you don't have to use your
     keyboard.



More information about the plug mailing list