View process hierarcy from the command line - pstree

  • September 7, 2007
  • Avatar for peter
    Peter
    Upfold

The commands ps and top are very useful for seeing what's running on your system. Operating systems like Linux though actually have a hierarchical system of processes, and by default neither of those two show you that hierarchy.

That's where pstree comes in. As the name suggests, it shows you a tree-style list of processes in this hierarchy. As you can see, depending on the exact flavour of Unix you're running, there might be a different name, but there will be a 'father' process that is right at the top.

pstree

In the case of Linux, that's init. You'll notice that in your output, all processes are underneath this one. You might also discover some interesting relationships between different processes.

It also might turn out useful if something goes awry on your system and if you need to identify the root culprit of a problem (for example if the parent process spawns a child which locks up).

Whether it's out of sheer curiosity, to troubleshoot, or for something else, pstree is a useful tool to have in your command line toolkit.

Avatar for peter Peter Upfold

Home » Articles »