pstree Command in Linux with Examples
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.
Please Login to comment...