pstree Command in Linux: View the Process Tree

When working on a Linux machine, you may need to find out what processes are currently running. There are a number of commands you can use to inspect running processes, with ps and top being the most commonly used ones.
In this article, we will talk about the pstree command. It is similar to ps
, but instead of listing the running processes, it shows them in a tree. The tree-like format is a more convenient way to display the processes hierarchy and makes the output more visually appealing.
How to Use the pstree Command
The general syntax for the pstree command is as follows:
pstree [OPTIONS] [USER or PID]In its simplest form when invoked without any option or argument, pstree displays a hierarchical tree structure of all running processes:
pstreesystemd─┬─VBoxService───7*[{VBoxService}]
├─accounts-daemon───2*[{accounts-daemon}]
├─2*[agetty]
├─atd
├─cron
├─dbus-daemon
├─irqbalance───{irqbalance}
├─2*[iscsid]
├─lvmetad
├─lxcfs───2*[{lxcfs}]
├─networkd-dispat───{networkd-dispat}
├─nginx───2*[nginx]
...The top/root item in the tree is the parent process of all system processes. In this example that is systemd, which is the first process that starts on boot.
pstree merges identical branches by putting them between square brackets and prefixing them with an integer that represents the number of branches. This makes the output more readable and visually appealing.
Below is an example showing how the square brackets are used:
├─2*[agetty]is same as:
├─agetty
├─agettyTo disable the merging of the identical branches, use the -c option:
pstree -cThe threads of a process are shown under the parent process and displayed using the process name inside curly braces. Here is an example:
├─lxcfs───2*[{lxcfs}]Use the -t option to show the full thread names. If you want to hide threads and show only processes use the -T option.
Typically, pstree displays many lines of output that do not fit on the screen. To view the output one page at a time, pipe it to the less
command:
pstree | lessIf a user name is given as an argument, pstree shows only the processes owned by that user. For example, the following command will show only those processes that have been started by a user named “linuxize”:
pstree linuxizeWhen PID is specified as an argument, pstree displays a tree with the given process as the root of the tree. Here is an example:
pstree 1943sshd───bash───pstreeTo show the parent processes of the given process use the -s option followed by the process PID:
pstree -s 1943systemd───sshd───sshd───bash───pstreeShow PIDs and PGIDs
Usually, when running the pstree command, the most important information the user is looking for is the process ID. For example, knowing the PID allows you to kill a malfunctioning process
.
The -p option instructs pstree to show the PIDs:
pstree -pPIDs are shown in parentheses after each process or thread.
systemd(1)─┬─VBoxService(955)─┬─{VBoxService}(956)
│ ├─{VBoxService}(957)
│ ├─{VBoxService}(958)
│ ├─{VBoxService}(959)
│ ├─{VBoxService}(960)
│ ├─{VBoxService}(961)
│ └─{VBoxService}(962)
...By default, pstree sorts processes with the same parent by name. The -n option tells pstree to use numeric sort, i.e. sort by PIDs:
pstree -pnThe process group ID (PGID) is the process ID of the first member of the process group. To view PGIDs use the -g option:
pstree -gPGIDs are shown in parentheses after each process or thread.
systemd(1)─┬─VBoxService(954)─┬─{VBoxService}(954)
│ ├─{VBoxService}(954)
│ ├─{VBoxService}(954)
│ ├─{VBoxService}(954)
│ ├─{VBoxService}(954)
│ ├─{VBoxService}(954)
│ └─{VBoxService}(954)
...When PIDs or PGIDs are shown, merging is implicitly disabled.
Show Command Line Arguments
Some programs can be invoked with configuration options specified as command-line arguments.
By default, pstree does not show you the command line arguments for the running processes. To view how the process was started, use the command together with the -a option:
pstree -a...
├─agetty -o -p -- \\u --keep-baud 115200,38400,9600 ttyS0 vt220
├─agetty -o -p -- \\u --noclear tty1 linux
...Highlighting
pstree also allows you to highlight processes for better visual representation.
The -h option instructs pstree to highlight the current process and all its ancestors.
pstree -hTo highlight a specific process, use the -H option followed by the process ID:
pstree -H PID_NUMBERIf the highlighting is not supported, the command will exit with an error.
Quick Reference
| Command | Description |
|---|---|
pstree | Display all processes as a tree |
pstree USER | Show only processes owned by a user |
pstree PID | Show tree rooted at a specific PID |
pstree -p | Show PIDs next to each process |
pstree -g | Show PGIDs next to each process |
pstree -n | Sort by PID instead of name |
pstree -a | Show command-line arguments |
pstree -c | Disable merging of identical branches |
pstree -t | Show full thread names |
pstree -T | Hide threads, show only processes |
pstree -h | Highlight current process and its ancestors |
pstree -H PID | Highlight a specific process |
pstree -s PID | Show parent processes of a PID |
FAQ
Does pstree come pre-installed on Linux?
On most distributions it is included by default as part of the psmisc package. If it is missing, install it with sudo apt install psmisc on Ubuntu and Debian, or sudo dnf install psmisc on Fedora, RHEL, and derivatives.
What is the difference between pstree and ps?ps
lists processes as a flat table with detailed columns such as CPU and memory usage. pstree shows the same processes in a hierarchy that makes parent-child relationships immediately visible.
How do I find the PID of a process with pstree?
Run pstree -p to display PIDs in parentheses next to each process name. To narrow the output, pass a username or PID as an argument — for example, pstree -p 1 shows the full tree starting from PID 1.
Why does pstree show *[{process}] notation?
This is the merged-branch notation. 2*[{nginx}] means there are two identical thread entries. Use pstree -c to expand them individually.
Conclusion
The pstree command is a quick way to visualize the parent-child relationships between running processes. For a full list of options, run man pstree in your terminal.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page