Install
Install the pstree
with brew
:
$ brew install pstree
Show the help doc:
$ pstree --help
pstree: illegal option -- -
pstree $Revision: 2.39 $ by Fred Hucht (C) 1993-2015
EMail: fred AT thp.uni-due.de
Usage: pstree [-f file] [-g n] [-l n] [-u user] [-U] [-s string] [-p pid] [-w] [pid ...]
-f file read input from <file> (- is stdin) instead of running
"ps -axwwo user,pid,ppid,pgid,command"
-g n use graphics chars for tree. n=1: IBM-850, n=2: VT100, n=3: UTF-8
-l n print tree to n level deep
-u user show only branches containing processes of <user>
-U don't show branches containing only root processes
-s string show only branches containing process with <string> in commandline
-p pid show only branches containing process <pid>
-w wide output, not truncated to window width
pid ... process ids to start from, default is 1 (probably init)
Process group leaders are marked with '='.
Samples
Show the tree with the process name:
$ pstree -s terraform
-+= 00001 root /sbin/launchd
\-+= 50669 larry /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ ID
\-+= 51403 larry /bin/bash --rcfile /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213
\-+= 55301 larry terraform apply
\--- 55302 larry /Users/larry/Software/terraform/terraform apply
Show the tree with the process ID(Both parent and child process):
$ pstree -p 55301
-+= 00001 root /sbin/launchd
\-+= 50669 larry /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ ID
\-+= 51403 larry /bin/bash --rcfile /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213
\-+= 55301 larry terraform apply
\--- 55302 larry /Users/larry/Software/terraform/terraform apply
Show the tree with the process ID(child process):
$ pstree 55301
-+= 55301 larry terraform apply
\--- 55302 larry /Users/larry/Software/terraform/terraform apply