The best way to display the running process in a system is to display them as a tree hierarchy. In a Linux system, “pstree” helps visualize processes hierarchy which is a less complex way to display running processes.
The “pstree” command is one of the Linux commands that merge branches through square brackets and display the process as a tree. The root of the tree could be “init” or “pid”.
How to Use Pstree Commands in Linux
Type “pstree” command in terminal to display the hierarchy tree of all running process:
In the output, it displays the hierarchy tree structure in which systemd is the parent/root process of all the system process as it starts first when the system is booted.
Here are few examples to show the working of the “pstree” command in the Linux system:
You won’t see command-line arguments in output by default, so, to display it in the terminal, use the given command:
When you use the “-p” with “pstree” command in the terminal, it will display PIDS in output as a decimal number within parenthesis.
The “-c” option is used to extend “pstree” as it packed down subtrees and to display identical subtrees use:
The “-n” option in “pstree” helps to sort process in numeric order:
To display the user of the process, use the “-u” option with “pstree” in the terminal.
The “-h” option in “pstree” allows to highlight the current process with its ancestors:
To print IDs of process groups in the terminal, use “-g”:
To get detailed information about the “pstree” version, type the “-V” command:
The pstree command in Linux is used to display the running process of a system in a tree hierarchy. It makes an interesting way to merge branches and visualize them. Through this tutorial, we have learned that how to use “pstree” commands with examples.