pstree Command
Beginner Process Management man(1)Display processes as a tree showing parent-child relationships
👁 11 views
📅 Updated: Mar 15, 2026
SYNTAX
pstree [OPTION]... [PID|USER]
What Does pstree Do?
pstree displays running processes as a tree, showing parent-child relationships. It provides a visual hierarchy of how processes are spawned and organized on the system.
pstree merges identical branches by default, showing the count in brackets. This makes it easy to see how many worker processes a service has spawned.
pstree is useful for understanding process relationships, debugging fork bombs, finding parent processes of orphaned children, and visualizing service architectures.
pstree merges identical branches by default, showing the count in brackets. This makes it easy to see how many worker processes a service has spawned.
pstree is useful for understanding process relationships, debugging fork bombs, finding parent processes of orphaned children, and visualizing service architectures.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -p | Show PIDs alongside process names | pstree -p |
| -u | Show user transitions (uid changes) | pstree -u |
| -a | Show command line arguments | pstree -a |
| -h | Highlight current process and ancestors | pstree -h |
| -n | Sort by PID instead of name | pstree -n |
| -l | Long format (do not truncate) | pstree -l |
| -s | Show parents of a specific process | pstree -s 1234 |
Practical Examples
#1 View process tree
Shows all processes in a tree hierarchy.
$ pstree
Output:
systemd─┬─sshd───sshd───bash
├─nginx───4*[nginx]
└─php-fpm───8*[php-fpm]
#2 Tree with PIDs
Shows the tree with process IDs — useful for targeting specific processes.
$ pstree -p#3 Show specific user tree
Shows the process tree for the www-data user.
$ pstree www-data#4 Show parents of a process
Shows the full ancestry chain from PID 1 to process 1234.
$ pstree -s 1234
Output:
systemd───sshd───sshd───bash───python3
#5 Tree with arguments
Shows command line arguments for each process.
$ pstree -a#6 Show user changes
Shows where user transitions happen (useful for sudo/su tracking).
$ pstree -uTips & Best Practices
Quick service audit: pstree shows how many workers each service has: pstree | grep nginx reveals nginx───4*[nginx] meaning 4 workers.
Merged branches: pstree merges identical children. 4*[nginx] means 4 identical nginx worker processes. Use -c to show them individually.
Long lines truncated: Use -l to prevent truncation of long command lines. Without it, wide trees may be cut off.
Frequently Asked Questions
How do I see the parent of a process?
Use pstree -s PID to show the full ancestry from init/systemd down to the specific process.
How do I see all processes of a service?
Use pstree -p service_name or pstree PID to see the process and all its children with PIDs.
What does 4*[nginx] mean?
It means 4 identical nginx child processes. pstree merges duplicate branches and shows the count.
Related Commands
More Process Management Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →