Linux Command: pstree
Display processes as a tree showing parent-child relationships
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.
Syntax
pstree [OPTION]... [PID|USER]Key Options
-pโ Show PIDs alongside process names-uโ Show user transitions (uid changes)-aโ Show command line arguments-hโ Highlight current process and ancestors-nโ Sort by PID instead of name-lโ Long format (do not truncate)
Examples
View process tree
pstreeOutput: systemdโโฌโsshdโโโsshdโโโbash
โโnginxโโโ4*[nginx]
โโphp-fpmโโโ8*[php-fpm]
Tree with PIDs
pstree -pShow specific user tree
pstree www-dataPro Tips
- pstree shows how many workers each service has: pstree | grep nginx reveals nginxโโโ4*[nginx] meaning 4 workers.
- pstree merges identical children. 4*[nginx] means 4 identical nginx worker processes. Use -c to show them individually.
- Use -l to prevent truncation of long command lines. Without it, wide trees may be cut off.
Learn more: Full pstree reference โ
Related Resources