System and processes
The pstree command
Shows processes as a tree: which process launched which one.
Most useful options
-pShows the PID of each process in parentheses-aShows the command line arguments of each process-sShows the parent processes of the given process-uShows in parentheses the new uid when a process changes user relative to its parent-nSorts processes with the same parent by PID instead of by name-THides threads and shows only processesCopy-ready examples
$ pstreethe full process tree, from process 1.$ pstree -pthe same tree with PIDs, to locate a specific process.$ pstree -s $$the parents of your current shell ($$ is its PID): which process your terminal hangs from.$ pstree -T miguelthe process trees of user miguel, without threads.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| bash: pstree: command not found | pstree comes in the psmisc package, which is missing from minimal images and containers. | Install it with sudo apt install psmisc. The same package provides killall. |
Typical mistakes
- With no arguments it shows the tree from process 1: on systems with many processes the output is huge. Combine it with less.
- Threads appear in curly braces, like {name}, under their process. To hide them, use -T.
- If the kernel or the /proc mount hides information (hidepid), pstree shows those processes with question marks instead of names.
Differences from similar commands
FAQ
What does 4*[getty] mean?
That there are four identical processes with the same parent. pstree groups them into one branch to avoid repeating them; with -c you turn that compaction off.
How do I see the tree of a single process?
Pass its PID: pstree -p 1234. With -s instead you see upwards, the parents of that process.
How do I also show the full commands?
With -a, which shows the arguments. If the command line is swapped out, the process appears in parentheses.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course