Pstree command in Linux that shows the running processes as a tree which is a more convenient way to display the processes hierarchy and makes the output more visually appealing. The root of the tree is either init or the process with the given pid. Pstree can also be installed in other Unix systems.
pstree [options] [pid or username]
Working with Pstree Command
1. To display process tree
It produces process-related information in output.
2. To include command line arguments in output
We do this by using the “-a” command line option. This command now displays command line options for some processes.
3. To display PIDs
To display PIDs for each process name, we use “-p” option.
4. To force pstree to expand identical subtrees in output.
By default, the pstree command merges identical branches by putting them in square brackets and prefixing them with the repetition count. But we can also force the tool to expand identical trees, by using the “-c” command-line option.
5. To sort processes
If we want to sort processes with the same ancestor by PID instead of by name i.e. numeric sort, we use “-n” option.
6. To see who is the owner/user of a process
If we want to find out the owner of a process in parenthesis, use the “-u” option.
7. To highlight the current process or any other process
To highlight the current process and its ancestors use “-h” option. It highlights the specified process (by name/pid)
8. To show process group IDs in output
We can see that process group IDs are shown as decimal numbers in parentheses after each process name.
9. To make pstree display process tree specific to a user.
It we want to display all process trees rooted at processes owned by a specific user, for this, we have to pass the name of that user as input to the command.
10. To display version information.
When we want to display version information we use “-V” option.
- 'IPCS' command in Linux with examples
- select command in Linux with examples
- Sed Command in Linux/Unix with examples
- ZIP command in Linux with examples
- SORT command in Linux/Unix with examples
- Cat command in Linux with examples
- Head command in Linux with examples
- Tail command in Linux with examples
- wc command in Linux with examples
- tar command in Linux with examples
- atrm command in Linux with examples
- bc command in Linux with examples
- AWK command in Unix/Linux with examples
- tr command in Unix/Linux with examples
- mv command in Linux with examples
- Paste command in Linux with examples
- comm command in Linux with examples
- cmp Command in Linux with examples
- cut command in Linux with examples
- cp command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.