The Beginner’s Guide to pstree Command on Linux – Linux

pstree is a powerful and useful for displaying running processes in . Like its companion ps, it shows all running processes currently active on your logged-in system. The main difference is that the processes are organized in a tree instead of in a list. This tree shows processes in a parent-child relationship. The parent process is the spawning process, which creates all the child processes below it.

The structure pf pstree is similar to hierarchical directories on Unix systems like Linux and macOS. Using this structure you can quickly navigate through your process tree to discover what processes spawn or control each other. This allows for precise elimination of troublesome or out-of-control processes with the kill command.

To run the basic form of the command, open a Terminal window and type the following command, then press Enter:


This command alone will show a list of all running processes. The process at the very top (systemd in this case) is the parent process for everything running on your machine. Processes below it were spawned or open through systemd. Further layers of indentation indicate similar relationships, much like a family tree.

The basic structure of the pstree can be seen in the following iamage.

By default, processes with the same parent will be sorted alphabetically. There are other ways to sort in pstree using flags that we discuss below.

Like most Terminal programs, there's more to pstree than just the single command. In addition to the basic functionality of pstree, different flags can trigger more complicated output from the program.

In order to expose process-identifying information, we can use the -p flags, which shows process-identification numbers, or PIDs.


We can also sort processes by PID instead of name with the -n flag.


You might notice that the output of pstree often gets cut off at the edge of your terminal window. You can manage that with the -l flag which “wraps” long lines at the edge of your terminal screen.


However, that might make the output a little hard to read, as you can see above.

You can also see only parts of the process tree. There are two ways to do that. The first is with the -s flag, which allows you to see the parent of the child process you specify. You can call out processes with its PID.


You might also want to see processes spawned by a current user. If you're on a multi-user system, this can give you a good idea of who is doing what on your system. On a single user system, it's not as informative. To see the processes spawned under a user, just type the user's name after the main command.


That will show any commands executed under that user's account, whether through programs the user runs or through commands they explicitly execute.

As always, each version of Linux might have a slight twist on this command, but it should be very standard on popular installations. To get help with your version, type man pstree in your command line and press Enter to open the command's manual page, or “man page.” You can also view the basic man page for pstree.

You might also like
Leave A Reply

Your email address will not be published.