pstree Command Examples in Linux

pstree command is used to display the parent-child relationship in a hierarchical format. The output of this command is quite similar to the output of the ‘ps axjf’ command and the ‘ps -ef –forest’ command, as shown in the following command line:

$ pstree

The following screenshot displays the tree hierarchy of a single process with PID using the pstree command:

Display the tree hierarchy of a user’s processes by executing the command line given:

$ pstree -p geek

On execution of the preceding command, the PIDs assigned to each process are shown in parentheses after each process name.

pstree Command Example

1. To display the process tree:

# pstree 2210 

2. To show the command line arguments:

# pstree -a 

3. To Use ASCII characters to draw the tree:

# pstree -A 

4. To Disable compaction of identical subtrees:

# pstree -c 

5. To Use VT100 line drawing characters:

# pstree -G 

6. To Highlight the current process and its ancestors:

# pstree -h 

7. To highlight the specified process instead:

# pstree -H 

8. To Display long lines:

# pstree -l 

9. To Sort processes with the same ancestor by PID instead of by name:

# pstree -n 

10. To show PIDs:

# pstree -p 

11. To show the uid transactions:

# pstree -u 

12. To Use UTF-8 (Unicode) line drawing characters:

# pstree -U 

13. To display the version:

# pstree -V 

14. To show the security context:

# pstree -Z 
Related Post