pstree command
pstree shows processes and their children like a tree
Typical usage: diagnosing process issues, information gathering, troubleshootingIntroduction into pstree
The pstree command is a tool for Linux systems to show active processes, including their hierarchy. When a process has child processes, it will be listed one level deeper. Due to the format it is called a tree.
Example output:
systemd─┬─agetty
├─auditd───{auditd}
├─cron
├─dbus-daemon
├─dhclient
├─dovecot─┬─anvil
│ ├─config
│ └─log
├─nginx───2*[nginx]
├─qemu-ga───{qemu-ga}
├─sshd─┬─sshd───sshd───bash───su───bash
│ └─sshd───sshd───bash───su───bash───pstree
├─systemd───(sd-pam)
├─systemd-journal
├─systemd-logind
├─systemd-timesyn───{systemd-timesyn}
└─systemd-udevd
Installation
When pstree is not installed by default, it can be added to the system using the relevant software package.
Package information for pstree
| Operating system | Package name | Installation |
|---|---|---|
| AlmaLinux | psmisc | |
| Arch Linux | psmisc | |
| Debian | psmisc | |
| Fedora | psmisc | |
| Red Hat Enterprise Linux | psmisc | |
| Rocky Linux | psmisc | |
| openSUSE | psmisc | |
| Ubuntu | psmisc | |
Your Linux distribution using a different package? Share your feedback.
Usage
Available options
| Long option | Short option | Description |
|---|---|---|
| --color ARG | -C | Use color in output. ARG can be 'age' which marks oldest, recent and new processes |
| --ns-sort=TYPE | -N TYPE | Show processes sorted by a namespace (ipc, mnt, net, pid, time, user, uts) |
| --show-pids | -p | Include process ID (PID) |
Missing an option in this overview? Share your feedback.
Frequently Asked Questions
What is the pstree command and its purpose?
The pstree command is a command-line tool to show which processes and their children in a visual representation like a tree.
Which package provides the pstree command?
The command pstree is provided by the psmisc package.
Related and similar commands
Linux has a lot of tools and commands available and sometimes you just need that little other tool. Here is a list of commands that are similar or related to pstree:
| Command | Category | Summary |
|---|---|---|
| basename | files | Strips directory and file name suffix from a given path |
| chrt | processes | Sets Linux scheduler policy and priority for a process or command |
| kill | processes | Sending signals to processes |
| nice | processes | Runs commands with specified priority |
| numactl | processes | Controls NUMA policy for processes and shared memory |
| peekfd | processes | Tracks a process and show file descriptor activity |
| pidof | processes | Returns process IDs for a process name |
| pidstat | monitoring | Monitoring CPU, memory, and disk activity |
| pidwait | processes | Wait for process to stop |
| pmap | processes | Shows memory mapping of process |
| prtstat | processes | Shows process details for selected process like state, CPU and memory usage |
| pscap | capabilities | Display available capabilities for running processes |
| pslog | logging | Shows which log files a process has opened |
| pwdx | processes | Shows current working directory of a process |
| renice | processes | Changes the priority of running processes |
| slabtop | memory | Shows slab usage of kernel |
| smem | memory | Show memory usage including swap |
| strace | process inspection | Inspects running process |
| units | data conversion | Converts a unit into another one, like from Celcius to Fahrenheit |
| watch | processes | Monitors changes in output of specified command |
Also 💙 the command-line or terminal? Here is a set of cheat sheets for Linux to get more done from within the shell: