If you use Linux, you’ve most likely used ps, top, or htop to view currently running processes on the system. While these programs are useful, they don’t show the relationship of processes to each other.
pstree is a program that visualizes Linux processes as a tree. Here’s how you may install and use it on Linux.

What Is pstree?
pstree is a program that shows the processes as a tree-like structure. The parent processes are the “trunk” and the child processes are branches.
Using pstree for the first time revealshow Linux processes work. All Linux processes have the init process, which is systemd on most major mainstream distros, as their common ancestor.

How to Install pstree on Linux
pstree is such a useful utility that there’s a good chance it’s already installed on your system. If you try to run it and it isn’t, it’s available through your package manager. It’s part of thepsmiscsuite of utilities.
To install it on Debian and Ubuntu, type:

To install pstree on Arch Linux:
And on the Red Hat family of distros:
Use pstree to View Linux Processes as a Tree
Running pstree is simple. Just typepstreeat the command line. You’ll see a tree of all the processes running on your system.
Supplying a username as an argument will show all the processes that the user owns. For example, to see a tree of the superuser’s processes:

As with many other Linux programs, pstree has command-line options. you’re able to see the PIDs of the processes with the-poption:
To highlight the current process, that is, your current shell, use the-hoption.
You can highlight a certain PID with the-H(capitalH) option, followed by the PID number:
You can get a color-coded representation of the age of the processes with the-Coption, followed by the age value. This is currently the only argument that this option takes.
Processes spawned in the last 60 seconds will be displayed in green. Similarly, yellow represents processes that were started an hour ago. The remaining processes will be in red.
Now You Can See How Your Linux Processes Are Related
pstree gives you a hierarchical tree-like view of your running Linux processes, true to its name. you’re able to see how your processes flow out of the init process, and you can customize your view with different options.
Linux’s procfs also lets you see information on Linux processes right from the file system.