pstree Command in Linux with Examples

Last Updated : 31 Oct, 2025

The pstree command in Linux is a powerful tool that displays running processes as a tree structure. This visual representation makes it easier to understand the hierarchy of processes, providing a more intuitive view of how processes are related to each other. The root of the tree is either the `init` process or a process with a specified PID. While pstree comes pre-installed on most Linux distributions, it can also be installed on other Unix-like systems.

Basic Pstree Example

To display the basic process tree, simply run the pstree command without any options:

2024-10-07_11-39

Output:

2024-10-07_11-40

This output shows the hierarchical relationship between processes, with child processes indented under their parent processes.

Syntax

pstree [options] [pid or username]

Key Options of the pstree Command

Option

Description

-a

Show command line arguments

-p

Show PIDs

-c

Disable compaction of identical subtrees

-n

Sort processes with the same parent by PID

-u

Show uid transitions

-h

Highlight current process and its ancestors

-g

Show PGID numbers

-V

Display version information

1. Display Command Line Arguments (-a)

To include command line arguments in the output:

Display Command Line Arguments
-a option

Output:

Display Command Line Arguments
output

This output shows more detailed information about each process, including the command line arguments used to start them.

2. Display PIDs (-p)

To show Process IDs (PIDs) for each process:

Display PIDs
-p option

3. Disable Compaction of Identical Subtrees (-c)

By default, `pstree` compacts identical branches. Use the `-c` option to expand all subtrees:

Disable Compaction of Identical Subtrees
Disable Compaction of Identical Subtrees

4. Sort Processes by PID (-n)

To sort processes with the same parent by PID instead of by name:

Sort Processes by PID
Sort Processes by PID

5. Show User/Owner of Processes (-u)

To display the owner of each process:

Show User/Owner of Processes
Show User/Owner of Processes

6. Highlight Current Process (-h)

To highlight the current process and its ancestors:

Highlight Current Process
Highlight Current Process

7. Show Process Group IDs (-g)

To display process group IDs:

Show Process Group IDs
Show Process Group IDs

Advanced Usages of pstree Command

1. Display Process Tree for a Specific User

To show all process trees rooted at processes owned by a specific user:

Display Process Tree for a Specific User
Display Process Tree for a Specific User

Replace `username` with the actual username you want to investigate.

2. Display Version Information

To check the version of `pstree` installed on your system:

Display Version Information
Display Version Information

Output:

Output
Output
Comment

Explore