How to View Child Processes in Linux with pstree

Quick Linux Tip #65:

Question: How do I see all child processes spawned by a parent?

Try: pstree -pau 3456

Info: pstree displays process hierarchies. -p includes PIDs, -a shows full command arguments, and -u lists usernames. Curly braces {} indicate threads.

Examples:

  • $ pstree -pau $$  # View process tree starting from current shell
  • $ pstree -T  # Hide threads to show only main processes
  • $ pstree -sp 3456  # Show parent ancestors leading up to PID 3456

Note: pstree is useful for identifying orphaned processes and understanding child process trees. Threads shown inside {} share the parent process's memory space.




LinuxTeck.com
linuxteck@ubuntu:~$ pstree -pau 3456
sshd(3456)──bash(3457,linuxteck)──python3(4567)──{python3}(4568)
                                             ├─{python3}(4569)
                                             └─{python3}(4570)
             ├─bash(3458,linuxteck)──vim(5678)
             └─bash(3459,linuxteck)──tmux(6789)──bash(6790)
                                             ├─bash(6791)
                                             └─bash(6792)
linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #64: Write an ISO to USB on Linux NEXT ARTICLE Quick Linux Tip #66: How to Redirect stdout and stderr to Separate Files in Linux
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.