Introduction

Almost everybody should have hear about ps if you want to know more about it, you can read running processes on Linux

But today I will write about pstree, it is very similar to ps but instead of listing the processes it shows them in a tree, which is more intuitive and useful for some cases.

Another good feature of pstree is that it is easy to know which process is the parent and which ones are children, so this way you can terminate ‘kill’ the parent will all its children, instead of being killing process by process.

Syntax

pstree [-a|--arguments] [-c|--compact] [-h|--highlight-all|-Hpid|--highlight-pid pid] [-l|--long] [-n|--numeric-sort] [-p|--show-pids] [-u|--uid-changes] [-Z|--security-context] [-A|--ascii|-G|--vt100|-U|--unicode] [pid|user] pstree -V|--version

We’ll see some of the most used options, being the first, to use just as is, with no options or arguments.

pstree

Will show an output similar to this:

pstree

This show all processes running, if you want to know only those owned by a specific user.

pstree [user]

In my case

pstree ggarron

The output now is something like this:

pstree user

Some options I use are:

-a

Shows command line arguments, meaning the command which was used to start the process

-h

Highlight the current process and its ancestors. This is a no-op if the terminal doesn’t support high‐lighting or if neither the current process nor any of its ancestors are in the subtree being shown.

-p

Show PIDs. PIDs are shown as decimal number after each process name, useful to identify a process and be able to stop it using `kill`

Conclusion

pstree is a great command for the sysadmin, has a lot of other options, and you will learn to love it. Check the ps man page to learn more about it.