5+ “pstree” Command Usage Examples in Linux

«

This tutorial explains Linux “pstree” command, options and its usage with examples.

pstree – display a tree of processes

Description :

advertisement

pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.

pstree visually merges identical branches by putting them in square brackets and prefixing them with the repetition count.

Usage :

pstree [-a] [-c] [-h|-Hpid] [-l] [-n] [-p] [-u] [-G|-U] [pid|user] pstree -V

Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement

Options :

-a
Show command line arguments. If the command line of a process is swapped out, that process is shown in parentheses. -a implicitly disables compaction.
-c
Disable compaction of identical subtrees. By default, subtrees are compacted whenever possible.
-G
Use VT100 line drawing characters.
-h
Highlight the current process and its ancestors. This is a no-op if the terminal doesn’t support highlighting or if neither the current process nor any of its ancestors are in the subtree being shown.
-H
Like -h, but highlight the specified process instead. Unlike with -h, pstree fails when using -H if highlighting is not available.
-l
Display long lines. By default, lines are truncated to the display width or 132 if output is sent to a non-tty or if the display width is unknown.
-n
Sort processes with the same ancestor by PID instead of by name. (Numeric sort.)
-p
Show PIDs. PIDs are shown as decimal numbers in parentheses after each process name. -p implicitly disables compaction.
-u
Show uid transitions. Whenever the uid of a process differs from the uid of its parent, the new uid is shown in parentheses after the process name.
-U
Use UTF-8 (Unicode) line drawing characters. Under Linux 1.1-54 and above, UTF-8 mode is entered on the console with echo -e ‘\033%8’ and left with echo -e ‘\033%@’
-V
Display version information.
-s
(Flask) Show Security ID (SID) for each process.
-x
(Flask) Show security context for each process.

Examples :

1. Display process tree

advertisement
$ pstree
init---NetworkManager---dhclient
     ¦                +-dnsmasq
     ¦                +-3*[{NetworkManager}]
     +-accounts-daemon---2*[{accounts-daemon}]
     +-acpid
     +-at-spi-bus-laun---2*[{at-spi-bus-laun}]
     +-avahi-daemon---avahi-daemon
     +-bamfdaemon---3*[{bamfdaemon}]
     +-bluetoothd
     +-colord---{colord}
     +-console-kit-dae---64*[{console-kit-dae}]
     +-cron
     +-cups-browsed
     +-cupsd
     +-2*[dbus-daemon]
     +-dbus-launch
     +-dconf-service---2*[{dconf-service}]
     +-evolution-sourc---2*[{evolution-sourc}]
     +-gconfd-2
     +-6*[getty]
     +-gnome-keyring-d---7*[{gnome-keyring-d}]
     +-gnome-terminal---bash---pstree
     ¦                +-gnome-pty-helpe
     ¦                +-3*[{gnome-terminal}]
     +-gvfs-afc-volume---2*[{gvfs-afc-volume}]
     +-gvfs-gphoto2-vo---{gvfs-gphoto2-vo}
     +-gvfs-mtp-volume---{gvfs-mtp-volume}
     +-gvfs-udisks2-vo---{gvfs-udisks2-vo}
     +-gvfsd---{gvfsd}
     +-gvfsd-burn---2*[{gvfsd-burn}]
     +-gvfsd-fuse---4*[{gvfsd-fuse}]
     +-gvfsd-http---sh---pxgsettings---2*[{pxgsettings}]
     ¦            +-4*[{gvfsd-http}]
     +-gvfsd-metadata---{gvfsd-metadata}
     +-gvfsd-trash---6*[{gvfsd-trash}]
     +-hud-service---2*[{hud-service}]
     +-indicator-appli---{indicator-appli}
     +-indicator-bluet---2*[{indicator-bluet}]
     +-indicator-datet---3*[{indicator-datet}]
     +-indicator-messa---2*[{indicator-messa}]
     +-indicator-print---2*[{indicator-print}]
     +-indicator-sessi---2*[{indicator-sessi}]
     +-indicator-sound---2*[{indicator-sound}]
     +-indicator-sync----{indicator-sync-}
     +-lightdm---Xorg
     ¦         +-lightdm---gnome-session---compiz---3*[{compiz}]
     ¦         ¦         ¦               +-deja-dup-monito---2*[{deja-dup-monit+
     ¦         ¦         ¦               +-gnome-fallback----2*[{gnome-fallback+
     ¦         ¦         ¦               +-gnome-screensav---2*[{gnome-screensa+
     ¦         ¦         ¦               +-gnome-settings----check_gl_textur
     ¦         ¦         ¦               ¦                 +-2*[{gnome-settings+
     ¦         ¦         ¦               +-nautilus---3*[{nautilus}]
     ¦         ¦         ¦               +-nm-applet---3*[{nm-applet}]
     ¦         ¦         ¦               +-polkit-gnome-au---2*[{polkit-gnome-a+
     ¦         ¦         ¦               +-ssh-agent
     ¦         ¦         ¦               +-telepathy-indic---2*[{telepathy-indi+
     ¦         ¦         ¦               +-update-notifier---3*[{update-notifie+
     ¦         ¦         ¦               +-3*[{gnome-session}]
     ¦         ¦         +-{lightdm}
     ¦         +-2*[{lightdm}]
     +-mission-control---2*[{mission-control}]
     +-modem-manager
     +-notify-osd---2*[{notify-osd}]
     +-polkitd---{polkitd}
     +-pulseaudio---2*[{pulseaudio}]
     +-rsyslogd---3*[{rsyslogd}]
     +-rtkit-daemon---2*[{rtkit-daemon}]
     +-sh---gtk-window-deco---2*[{gtk-window-deco}]
     +-tpvmlp
     +-ubuntuone-syncd---3*[{ubuntuone-syncd}]
     +-udevd---2*[udevd]
     +-udisksd---4*[{udisksd}]
     +-unity-applicati---2*[{unity-applicati}]
     +-unity-files-dae---3*[{unity-files-dae}]
     +-unity-lens-frie---2*[{unity-lens-frie}]
     +-unity-lens-phot---sh---pxgsettings---2*[{pxgsettings}]
     ¦                 +-3*[{unity-lens-phot}]
     +-unity-music-dae---{unity-music-dae}
     +-unity-musicstor---2*[{unity-musicstor}]
     +-unity-panel-ser---2*[{unity-panel-ser}]
     +-unity-scope-gdr---3*[{unity-scope-gdr}]
     +-unity-scope-vid---sh---pxgsettings---2*[{pxgsettings}]
     ¦                 +-2*[{unity-scope-vid}]
     +-unity-shopping----sh---pxgsettings---2*[{pxgsettings}]
     ¦                 +-2*[{unity-shopping-}]
     +-unity-video-len---2*[{unity-video-len}]
     +-unity-webapps-s---2*[{unity-webapps-s}]
     +-update-manager---2*[{update-manager}]
     +-upowerd---2*[{upowerd}]
     +-upstart-file-br
     +-upstart-socket-
     +-upstart-udev-br
     +-vmtoolsd
     +-vmtoolsd---2*[{vmtoolsd}]
     +-vmware-vmblock----3*[{vmware-vmblock-}]
     +-whoopsie---{whoopsie}
     +-zeitgeist-daemo---{zeitgeist-daemo}
     +-zeitgeist-datah---2*[{zeitgeist-datah}]
     +-zeitgeist-fts---cat
                     +-{zeitgeist-fts}

2. Use ASCII characters to draw the tree by passing the -A option

$ pstree -A
init-+-NetworkManager-+-dhclient
     |                |-dnsmasq
     |                `-3*[{NetworkManager}]
     |-accounts-daemon---2*[{accounts-daemon}]
     |-acpid
     |-at-spi-bus-laun---2*[{at-spi-bus-laun}]
     |-avahi-daemon---avahi-daemon
     |-bamfdaemon---3*[{bamfdaemon}]
     |-bluetoothd
     |-colord---{colord}
     |-console-kit-dae---64*[{console-kit-dae}]
     |-cron
     |-cups-browsed
     |-cupsd
     |-2*[dbus-daemon]
     |-dbus-launch
     |-dconf-service---2*[{dconf-service}]
     |-evolution-sourc---2*[{evolution-sourc}]
     |-gconfd-2
     |-6*[getty]
     |-gnome-keyring-d---7*[{gnome-keyring-d}]
     |-gnome-terminal-+-bash---pstree
     |                |-gnome-pty-helpe
     |                `-3*[{gnome-terminal}]
     |-gvfs-afc-volume---2*[{gvfs-afc-volume}]
     |-gvfs-gphoto2-vo---{gvfs-gphoto2-vo}
     |-gvfs-mtp-volume---{gvfs-mtp-volume}
     |-gvfs-udisks2-vo---{gvfs-udisks2-vo}
     |-gvfsd---{gvfsd}
     |-gvfsd-burn---2*[{gvfsd-burn}]
     |-gvfsd-fuse---4*[{gvfsd-fuse}]
     |-gvfsd-http-+-sh---pxgsettings---2*[{pxgsettings}]
     |            `-4*[{gvfsd-http}]
     |-gvfsd-metadata---{gvfsd-metadata}
     |-gvfsd-trash---6*[{gvfsd-trash}]
     |-hud-service---2*[{hud-service}]
     |-indicator-appli---{indicator-appli}
     |-indicator-bluet---2*[{indicator-bluet}]
     |-indicator-datet---3*[{indicator-datet}]
     |-indicator-messa---2*[{indicator-messa}]
     |-indicator-print---2*[{indicator-print}]
     |-indicator-sessi---2*[{indicator-sessi}]
     |-indicator-sound---2*[{indicator-sound}]
     |-indicator-sync----{indicator-sync-}
     |-lightdm-+-Xorg
     |         |-lightdm-+-gnome-session-+-compiz---3*[{compiz}]
     |         |         |               |-deja-dup-monito---2*[{deja-dup-monit+
     |         |         |               |-gnome-fallback----2*[{gnome-fallback+
     |         |         |               |-gnome-screensav---2*[{gnome-screensa+
     |         |         |               |-gnome-settings--+-check_gl_textur
     |         |         |               |                 `-2*[{gnome-settings+
     |         |         |               |-nautilus---3*[{nautilus}]
     |         |         |               |-nm-applet---3*[{nm-applet}]
     |         |         |               |-polkit-gnome-au---2*[{polkit-gnome-a+
     |         |         |               |-ssh-agent
     |         |         |               |-telepathy-indic---2*[{telepathy-indi+
     |         |         |               |-update-notifier---3*[{update-notifie+
     |         |         |               `-3*[{gnome-session}]
     |         |         `-{lightdm}
     |         `-2*[{lightdm}]
     |-mission-control---2*[{mission-control}]
     |-modem-manager
     |-notify-osd---2*[{notify-osd}]
     |-polkitd---{polkitd}
     |-pulseaudio---2*[{pulseaudio}]
     |-rsyslogd---3*[{rsyslogd}]
     |-rtkit-daemon---2*[{rtkit-daemon}]
     |-sh---gtk-window-deco---2*[{gtk-window-deco}]
     |-tpvmlp
     |-ubuntuone-syncd---3*[{ubuntuone-syncd}]
     |-udevd---2*[udevd]
     |-udisksd---4*[{udisksd}]
     |-unity-applicati---2*[{unity-applicati}]
     |-unity-files-dae---3*[{unity-files-dae}]
     |-unity-lens-frie---2*[{unity-lens-frie}]
     |-unity-lens-phot-+-sh---pxgsettings---2*[{pxgsettings}]
     |                 `-3*[{unity-lens-phot}]
     |-unity-music-dae---{unity-music-dae}
     |-unity-musicstor---2*[{unity-musicstor}]
     |-unity-panel-ser---2*[{unity-panel-ser}]
     |-unity-scope-gdr---3*[{unity-scope-gdr}]
     |-unity-scope-vid-+-sh---pxgsettings---2*[{pxgsettings}]
     |                 `-2*[{unity-scope-vid}]
     |-unity-shopping--+-sh---pxgsettings---2*[{pxgsettings}]
     |                 `-2*[{unity-shopping-}]
     |-unity-video-len---2*[{unity-video-len}]
     |-unity-webapps-s---2*[{unity-webapps-s}]
     |-update-manager---2*[{update-manager}]
     |-upowerd---2*[{upowerd}]
     |-upstart-file-br
     |-upstart-socket-
     |-upstart-udev-br
     |-vmtoolsd
     |-vmtoolsd---2*[{vmtoolsd}]
     |-vmware-vmblock----3*[{vmware-vmblock-}]
     |-whoopsie---{whoopsie}
     |-zeitgeist-daemo---{zeitgeist-daemo}
     |-zeitgeist-datah---2*[{zeitgeist-datah}]
     `-zeitgeist-fts-+-cat
                     `-{zeitgeist-fts}

3. Display command line arguments along-with tree

$ pstree -a
init
  +-NetworkManager
  ¦   +-dhclient -d -sf /usr/lib/NetworkManager/nm-dhcp-client.action -pf...
  ¦   +-dnsmasq --no-resolv --keep-in-foreground --no-hosts ...
  ¦   +-3*[{NetworkManager}]
  +-accounts-daemon
  ¦   +-2*[{accounts-daemon}]
  +-acpid -c /etc/acpi/events -s /var/run/acpid.socket
  +-at-spi-bus-laun
  ¦   +-2*[{at-spi-bus-laun}]
  +-avahi-daemon
  ¦   +-avahi-daemon
  +-bamfdaemon
  ¦   +-3*[{bamfdaemon}]
  +-bluetoothd
  +-colord
  ¦   +-{colord}
  +-console-kit-dae --no-daemon
  ¦   +-64*[{console-kit-dae}]
  +-cron
  +-cups-browsed
  +-cupsd -F
  +-dbus-daemon --system --fork
  +-dbus-daemon --fork --print-pid 5 --print-address 7 --session
  +-dbus-launch --exit-with-session /usr/bin/im-launch gnome-session--sess
  +-dconf-service
  ¦   +-2*[{dconf-service}]
  +-evolution-sourc
  ¦   +-2*[{evolution-sourc}]
  +-gconfd-2
  +-getty -8 38400 tty4
  +-getty -8 38400 tty5
  +-getty -8 38400 tty2
  +-getty -8 38400 tty3
  +-getty -8 38400 tty6
  +-getty -8 38400 tty1
  +-gnome-keyring-d --daemonize --login
  ¦   +-7*[{gnome-keyring-d}]
  +-gnome-terminal
  ¦   +-bash
  ¦   ¦   +-pstree -a
  ¦   +-gnome-pty-helpe
  ¦   +-3*[{gnome-terminal}]
  +-gvfs-afc-volume
  ¦   +-2*[{gvfs-afc-volume}]
  +-gvfs-gphoto2-vo
  ¦   +-{gvfs-gphoto2-vo}
  +-gvfs-mtp-volume
  ¦   +-{gvfs-mtp-volume}
  +-gvfs-udisks2-vo
  ¦   +-{gvfs-udisks2-vo}
  +-gvfsd
  ¦   +-{gvfsd}
  +-gvfsd-burn --spawner :1.6 /org/gtk/gvfs/exec_spaw/1
  ¦   +-2*[{gvfsd-burn}]
  +-gvfsd-fuse -f /run/user/mohakkataria/gvfs
  ¦   +-4*[{gvfsd-fuse}]
  +-gvfsd-http --spawner :1.6 /org/gtk/gvfs/exec_spaw/2
  ¦   +-sh -c...
  ¦   ¦   +-pxgsettings org.gnome.system.proxyorg.
  ¦   ¦       +-2*[{pxgsettings}]
  ¦   +-4*[{gvfsd-http}]
  +-gvfsd-metadata
  ¦   +-{gvfsd-metadata}
  +-gvfsd-trash --spawner :1.6 /org/gtk/gvfs/exec_spaw/0
  ¦   +-6*[{gvfsd-trash}]
  +-hud-service
  ¦   +-2*[{hud-service}]
  +-indicator-appli
  ¦   +-{indicator-appli}
  +-indicator-bluet
  ¦   +-2*[{indicator-bluet}]
  +-indicator-datet
  ¦   +-3*[{indicator-datet}]
  +-indicator-messa
  ¦   +-2*[{indicator-messa}]
  +-indicator-print
  ¦   +-2*[{indicator-print}]
  +-indicator-sessi
  ¦   +-2*[{indicator-sessi}]
  +-indicator-sound
  ¦   +-2*[{indicator-sound}]
  +-indicator-sync-
  ¦   +-{indicator-sync-}
  +-lightdm
  ¦   +-Xorg :0 -core -auth /var/run/lightdm/root/:0 -nolisten tcp vt7...
  ¦   +-lightdm --session-child 12 31
  ¦   ¦   +-gnome-session --session=ubuntu
  ¦   ¦   ¦   +-compiz
  ¦   ¦   ¦   ¦   +-3*[{compiz}]
  ¦   ¦   ¦   +-deja-dup-monito
  ¦   ¦   ¦   ¦   +-2*[{deja-dup-monito}]
  ¦   ¦   ¦   +-gnome-fallback-
  ¦   ¦   ¦   ¦   +-2*[{gnome-fallback-}]
  ¦   ¦   ¦   +-gnome-screensav
  ¦   ¦   ¦   ¦   +-2*[{gnome-screensav}]
  ¦   ¦   ¦   +-gnome-settings-
  ¦   ¦   ¦   ¦   +-(check_gl_textur)
  ¦   ¦   ¦   ¦   +-2*[{gnome-settings-}]
  ¦   ¦   ¦   +-nautilus -n
  ¦   ¦   ¦   ¦   +-3*[{nautilus}]
  ¦   ¦   ¦   +-nm-applet
  ¦   ¦   ¦   ¦   +-3*[{nm-applet}]
  ¦   ¦   ¦   +-polkit-gnome-au
  ¦   ¦   ¦   ¦   +-2*[{polkit-gnome-au}]
  ¦   ¦   ¦   +-ssh-agent /usr/bin/dbus-launch --exit-with-session ...
  ¦   ¦   ¦   +-telepathy-indic
  ¦   ¦   ¦   ¦   +-2*[{telepathy-indic}]
  ¦   ¦   ¦   +-update-notifier
  ¦   ¦   ¦   ¦   +-3*[{update-notifier}]
  ¦   ¦   ¦   +-3*[{gnome-session}]
  ¦   ¦   +-{lightdm}
  ¦   +-2*[{lightdm}]
  +-mission-control
  ¦   +-2*[{mission-control}]
  +-modem-manager
  +-notify-osd
  ¦   +-2*[{notify-osd}]
  +-polkitd --no-debug
  ¦   +-{polkitd}
  +-pulseaudio --start --log-target=syslog
  ¦   +-2*[{pulseaudio}]
  +-rsyslogd -c5
  ¦   +-3*[{rsyslogd}]
  +-rtkit-daemon
  ¦   +-2*[{rtkit-daemon}]
  +-sh -c /usr/bin/gtk-window-decorator
  ¦   +-gtk-window-deco
  ¦       +-2*[{gtk-window-deco}]
  +-tpvmlp
  +-ubuntuone-syncd /usr/lib/ubuntuone-client/ubuntuone-syncdaemon
  ¦   +-3*[{ubuntuone-syncd}]
  +-udevd --daemon
  ¦   +-udevd --daemon
  ¦   +-udevd --daemon
  +-udisksd --no-debug
  ¦   +-4*[{udisksd}]
  +-unity-applicati
  ¦   +-2*[{unity-applicati}]
  +-unity-files-dae
  ¦   +-3*[{unity-files-dae}]
  +-unity-lens-frie
  ¦   +-2*[{unity-lens-frie}]
  +-unity-lens-phot /usr/lib/unity-lens-photos/unity-lens-photos
  ¦   +-sh -c...
  ¦   ¦   +-pxgsettings org.gnome.system.proxyorg.
  ¦   ¦       +-2*[{pxgsettings}]
  ¦   +-3*[{unity-lens-phot}]
  +-unity-music-dae
  ¦   +-{unity-music-dae}
  +-unity-musicstor
  ¦   +-2*[{unity-musicstor}]
  +-unity-panel-ser
  ¦   +-2*[{unity-panel-ser}]
  +-unity-scope-gdr /usr/lib/unity-lens-files/unity-scope-gdrive
  ¦   +-3*[{unity-scope-gdr}]
  +-unity-scope-vid
  ¦   +-sh -c...
  ¦   ¦   +-pxgsettings org.gnome.system.proxyorg.
  ¦   ¦       +-2*[{pxgsettings}]
  ¦   +-2*[{unity-scope-vid}]
  +-unity-shopping-
  ¦   +-sh -c...
  ¦   ¦   +-pxgsettings org.gnome.system.proxyorg.
  ¦   ¦       +-2*[{pxgsettings}]
  ¦   +-2*[{unity-shopping-}]
  +-unity-video-len
  ¦   +-2*[{unity-video-len}]
  +-unity-webapps-s
  ¦   +-2*[{unity-webapps-s}]
  +-update-manager /usr/bin/update-manager --no-update --no-focus-on-map
  ¦   +-2*[{update-manager}]
  +-upowerd
  ¦   +-2*[{upowerd}]
  +-upstart-file-br --daemon
  +-upstart-socket- --daemon
  +-upstart-udev-br --daemon
  +-vmtoolsd
  +-vmtoolsd -n vmusr --blockFd 3
  ¦   +-2*[{vmtoolsd}]
  +-vmware-vmblock- -osubtype=vmware-vmblock,default_permissions,allo
  ¦   +-3*[{vmware-vmblock-}]
  +-whoopsie
  ¦   +-{whoopsie}
  +-zeitgeist-daemo
  ¦   +-{zeitgeist-daemo}
  +-zeitgeist-datah
  ¦   +-2*[{zeitgeist-datah}]
  +-zeitgeist-fts
      +-cat
      +-{zeitgeist-fts}

4. Display PIDs

advertisement
$ pstree -p
init(1)---NetworkManager(905)---dhclient(18540)
        ¦                     +-dnsmasq(1199)
        ¦                     +-{NetworkManager}(906)
        ¦                     +-{NetworkManager}(913)
        ¦                     +-{NetworkManager}(946)
        +-accounts-daemon(1345)---{accounts-daemon}(1350)
        ¦                       +-{accounts-daemon}(1414)
        +-acpid(1035)
        +-at-spi-bus-laun(10192)---{at-spi-bus-laun}(10193)
        ¦                        +-{at-spi-bus-laun}(10195)
        +-avahi-daemon(627)---avahi-daemon(629)
        +-bamfdaemon(7329)---{bamfdaemon}(7335)
        ¦                  +-{bamfdaemon}(7336)
        ¦                  +-{bamfdaemon}(7338)
        +-bluetoothd(599)
        +-colord(911)---{colord}(927)
        +-console-kit-dae(1481)---{console-kit-dae}(1488)
        ¦                       +-{console-kit-dae}(1489)
        ¦                       +-{console-kit-dae}(1490)
        ¦                       +-{console-kit-dae}(1491)
        ¦                       +-{console-kit-dae}(1492)
        ¦                       +-{console-kit-dae}(1493)
        ¦                       +-{console-kit-dae}(1494)
        ¦                       +-{console-kit-dae}(1495)
        ¦                       +-{console-kit-dae}(1496)
        ¦                       +-{console-kit-dae}(1497)
        ¦                       +-{console-kit-dae}(1498)
        ¦                       +-{console-kit-dae}(1499)
        ¦                       +-{console-kit-dae}(1500)
        ¦                       +-{console-kit-dae}(1501)
        ¦                       +-{console-kit-dae}(1502)
        ¦                       +-{console-kit-dae}(1503)
        ¦                       +-{console-kit-dae}(1504)
        ¦                       +-{console-kit-dae}(1505)
        ¦                       +-{console-kit-dae}(1506)
        ¦                       +-{console-kit-dae}(1507)
        ¦                       +-{console-kit-dae}(1508)
        ¦                       +-{console-kit-dae}(1509)
        ¦                       +-{console-kit-dae}(1510)
        ¦                       +-{console-kit-dae}(1511)
        ¦                       +-{console-kit-dae}(1512)
        ¦                       +-{console-kit-dae}(1513)
        ¦                       +-{console-kit-dae}(1514)
        ¦                       +-{console-kit-dae}(1515)
        ¦                       +-{console-kit-dae}(1516)
        ¦                       +-{console-kit-dae}(1517)
        ¦                       +-{console-kit-dae}(1518)
        ¦                       +-{console-kit-dae}(1519)
        ¦                       +-{console-kit-dae}(1520)
        ¦                       +-{console-kit-dae}(1521)
        ¦                       +-{console-kit-dae}(1522)
        ¦                       +-{console-kit-dae}(1523)
        ¦                       +-{console-kit-dae}(1524)
        ¦                       +-{console-kit-dae}(1525)
        ¦                       +-{console-kit-dae}(1526)
        ¦                       +-{console-kit-dae}(1527)
        ¦                       +-{console-kit-dae}(1528)
        ¦                       +-{console-kit-dae}(1529)
        ¦                       +-{console-kit-dae}(1530)
        ¦                       +-{console-kit-dae}(1531)
        ¦                       +-{console-kit-dae}(1532)
        ¦                       +-{console-kit-dae}(1533)
        ¦                       +-{console-kit-dae}(1534)
        ¦                       +-{console-kit-dae}(1535)
        ¦                       +-{console-kit-dae}(1536)
        ¦                       +-{console-kit-dae}(1537)
        ¦                       +-{console-kit-dae}(1538)
        ¦                       +-{console-kit-dae}(1539)
        ¦                       +-{console-kit-dae}(1540)
        ¦                       +-{console-kit-dae}(1541)
        ¦                       +-{console-kit-dae}(1542)
        ¦                       +-{console-kit-dae}(1543)
        ¦                       +-{console-kit-dae}(1544)
        ¦                       +-{console-kit-dae}(1545)
        ¦                       +-{console-kit-dae}(1546)
        ¦                       +-{console-kit-dae}(1547)
        ¦                       +-{console-kit-dae}(1548)
        ¦                       +-{console-kit-dae}(1549)
        ¦                       +-{console-kit-dae}(1613)
        ¦                       +-{console-kit-dae}(1614)
        +-cron(1063)
        +-cups-browsed(924)
        +-cupsd(793)
        +-dbus-daemon(480)
        +-dbus-daemon(7177)
        +-dbus-launch(7176)
        +-dconf-service(7236)---{dconf-service}(7237)
        ¦                     +-{dconf-service}(7238)
        +-evolution-sourc(7432)---{evolution-sourc}(7433)
        ¦                       +-{evolution-sourc}(7435)
        +-gconfd-2(7287)
        +-getty(970)
        +-getty(975)
        +-getty(1014)
        +-getty(1015)
        +-getty(1019)
        +-getty(1463)
        +-gnome-keyring-d(7117)---{gnome-keyring-d}(7118)
        ¦                       +-{gnome-keyring-d}(7192)
        ¦                       +-{gnome-keyring-d}(7193)
        ¦                       +-{gnome-keyring-d}(7194)
        ¦                       +-{gnome-keyring-d}(7436)
        ¦                       +-{gnome-keyring-d}(7517)
        ¦                       +-{gnome-keyring-d}(7584)
        +-gnome-terminal(11413)---bash(11424)---pstree(18889)
        ¦                       +-gnome-pty-helpe(11423)
        ¦                       +-{gnome-terminal}(11417)
        ¦                       +-{gnome-terminal}(11418)
        ¦                       +-{gnome-terminal}(11428)
        +-gvfs-afc-volume(7277)---{gvfs-afc-volume}(7278)
        ¦                       +-{gvfs-afc-volume}(7280)
        +-gvfs-gphoto2-vo(7273)---{gvfs-gphoto2-vo}(7275)
        +-gvfs-mtp-volume(7268)---{gvfs-mtp-volume}(7271)
        +-gvfs-udisks2-vo(7253)---{gvfs-udisks2-vo}(7262)
        +-gvfsd(7210)---{gvfsd}(7211)
        +-gvfsd-burn(7298)---{gvfsd-burn}(7299)
        ¦                  +-{gvfsd-burn}(7301)
        +-gvfsd-fuse(7214)---{gvfsd-fuse}(7218)
        ¦                  +-{gvfsd-fuse}(7219)
        ¦                  +-{gvfsd-fuse}(7220)
        ¦                  +-{gvfsd-fuse}(7221)
        +-gvfsd-http(7635)---sh(7645)---pxgsettings(7647)---{pxgsettings}(7653)
        ¦                  ¦                              +-{pxgsettings}(7657)
        ¦                  +-{gvfsd-http}(7638)
        ¦                  +-{gvfsd-http}(7644)
        ¦                  +-{gvfsd-http}(10495)
        ¦                  +-{gvfsd-http}(11147)
        +-gvfsd-metadata(9684)---{gvfsd-metadata}(9692)
        +-gvfsd-trash(7292)---{gvfsd-trash}(7293)
        ¦                   +-{gvfsd-trash}(7296)
        ¦                   +-{gvfsd-trash}(7302)
        ¦                   +-{gvfsd-trash}(7303)
        ¦                   +-{gvfsd-trash}(14590)
        ¦                   +-{gvfsd-trash}(14592)
        +-hud-service(7355)---{hud-service}(7365)
        ¦                   +-{hud-service}(7366)
        +-indicator-appli(7390)---{indicator-appli}(7406)
        +-indicator-bluet(7391)---{indicator-bluet}(7417)
        ¦                       +-{indicator-bluet}(7421)
        +-indicator-datet(7388)---{indicator-datet}(7426)
        ¦                       +-{indicator-datet}(7428)
        ¦                       +-{indicator-datet}(7429)
        +-indicator-messa(7386)---{indicator-messa}(7416)
        ¦                       +-{indicator-messa}(7420)
        +-indicator-print(7384)---{indicator-print}(7430)
        ¦                       +-{indicator-print}(7434)
        +-indicator-sessi(7379)---{indicator-sessi}(7395)
        ¦                       +-{indicator-sessi}(7396)
        +-indicator-sound(7378)---{indicator-sound}(7409)
        ¦                       +-{indicator-sound}(7427)
        +-indicator-sync-(7382)---{indicator-sync-}(7399)
        +-lightdm(1086)---Xorg(6920)
        ¦               +-lightdm(7011)---gnome-session(7127)---compiz(14575)--+++
        ¦               ¦               ¦                     ¦               ++++
        ¦               ¦               ¦                     ¦               ++++
        ¦               ¦               ¦                     +-deja-dup-monito+
        ¦               ¦               ¦                     +-gnome-fallback-+
        ¦               ¦               ¦                     +-gnome-screensav+
        ¦               ¦               ¦                     +-gnome-settings-+
        ¦               ¦               ¦                     +-nautilus(7239)-+++
        ¦               ¦               ¦                     ¦                +++
        ¦               ¦               ¦                     ¦                +++
        ¦               ¦               ¦                     +-nm-applet(7247)+++
        ¦               ¦               ¦                     +-polkit-gnome-au+
        ¦               ¦               ¦                     +-ssh-agent(7173)
        ¦               ¦               ¦                     +-telepathy-indic+
        ¦               ¦               ¦                     +-update-notifier+
        ¦               ¦               ¦                     +-{gnome-session}+
        ¦               ¦               ¦                     +-{gnome-session}+
        ¦               ¦               ¦                     +-{gnome-session}+
        ¦               ¦               +-{lightdm}(7078)
        ¦               +-{lightdm}(1101)
        ¦               +-{lightdm}(1102)
        +-mission-control(7727)---{mission-control}(7730)
        ¦                       +-{mission-control}(7732)
        +-modem-manager(834)
        +-notify-osd(9980)---{notify-osd}(9981)
        ¦                  +-{notify-osd}(9982)
        +-polkitd(915)---{polkitd}(919)
        +-pulseaudio(7205)---{pulseaudio}(7217)
        ¦                  +-{pulseaudio}(7222)
        +-rsyslogd(386)---{rsyslogd}(475)
        ¦               +-{rsyslogd}(476)
        ¦               +-{rsyslogd}(477)
        +-rtkit-daemon(1930)---{rtkit-daemon}(1932)
        ¦                    +-{rtkit-daemon}(1933)
        +-sh(7350)---gtk-window-deco(7351)---{gtk-window-deco}(7360)
        ¦                                  +-{gtk-window-deco}(7364)
        +-tpvmlp(1382)
        +-ubuntuone-syncd(7758)---{ubuntuone-syncd}(7759)
        ¦                       +-{ubuntuone-syncd}(7777)
        ¦                       +-{ubuntuone-syncd}(7780)
        +-udevd(355)---udevd(12321)
        ¦            +-udevd(12322)
        +-udisksd(2171)---{udisksd}(2173)
        ¦               +-{udisksd}(2175)
        ¦               +-{udisksd}(2177)
        ¦               +-{udisksd}(2190)
        +-unity-applicati(7456)---{unity-applicati}(7475)
        ¦                       +-{unity-applicati}(7506)
        +-unity-files-dae(7454)---{unity-files-dae}(7470)
        ¦                       +-{unity-files-dae}(7503)
        ¦                       +-{unity-files-dae}(7595)
        +-unity-lens-frie(7453)---{unity-lens-frie}(7469)
        ¦                       +-{unity-lens-frie}(7488)
        +-unity-lens-phot(7457)---sh(7573)---pxgsettings(7574)---{pxgsettings}(+
        ¦                       ¦                              +-{pxgsettings}(+
        ¦                       +-{unity-lens-phot}(7558)
        ¦                       +-{unity-lens-phot}(7572)
        ¦                       +-{unity-lens-phot}(7594)
        +-unity-music-dae(7455)---{unity-music-dae}(7464)
        +-unity-musicstor(7616)---{unity-musicstor}(7617)
        ¦                       +-{unity-musicstor}(7618)
        +-unity-panel-ser(7353)---{unity-panel-ser}(7373)
        ¦                       +-{unity-panel-ser}(7374)
        +-unity-scope-gdr(7580)---{unity-scope-gdr}(7606)
        ¦                       +-{unity-scope-gdr}(7607)
        ¦                       +-{unity-scope-gdr}(7614)
        +-unity-scope-vid(7579)---sh(7585)---pxgsettings(7586)---{pxgsettings}(+
        ¦                       ¦                              +-{pxgsettings}(+
        ¦                       +-{unity-scope-vid}(7581)
        ¦                       +-{unity-scope-vid}(7582)
        +-unity-shopping-(7459)---sh(7547)---pxgsettings(7549)---{pxgsettings}(+
        ¦                       ¦                              +-{pxgsettings}(+
        ¦                       +-{unity-shopping-}(7479)
        ¦                       +-{unity-shopping-}(7516)
        +-unity-video-len(7461)---{unity-video-len}(7476)
        ¦                       +-{unity-video-len}(7524)
        +-unity-webapps-s(10179)---{unity-webapps-s}(10183)
        ¦                        +-{unity-webapps-s}(10189)
        +-update-manager(12196)---{update-manager}(12206)
        ¦                       +-{update-manager}(12208)
        +-upowerd(1706)---{upowerd}(1707)
        ¦               +-{upowerd}(1708)
        +-upstart-file-br(284)
        +-upstart-socket-(803)
        +-upstart-udev-br(352)
        +-vmtoolsd(1305)
        +-vmtoolsd(7254)---{vmtoolsd}(7339)
        ¦                +-{vmtoolsd}(7349)
        +-vmware-vmblock-(1237)---{vmware-vmblock-}(1240)
        ¦                       +-{vmware-vmblock-}(1241)
        ¦                       +-{vmware-vmblock-}(14130)
        +-whoopsie(1236)---{whoopsie}(1243)
        ¦                +-{whoopsie}(18887)
        +-zeitgeist-daemo(7519)---{zeitgeist-daemo}(7523)
        +-zeitgeist-datah(7543)---{zeitgeist-datah}(7551)
        ¦                       +-{zeitgeist-datah}(11120)
        +-zeitgeist-fts(7542)---cat(7546)
                              +-{zeitgeist-fts}(7545)

5. Numeric Sort using -n option

To sort processes with the same ancestor by PID instead of by name i.e. numeric sort, pass the -n options as follows:

$ pstree -np
init(1)---upstart-file-br(284)
        +-upstart-udev-br(352)
        +-udevd(355)---udevd(12321)
        ¦            +-udevd(12322)
        +-rsyslogd(386)---{rsyslogd}(475)
        ¦               +-{rsyslogd}(476)
        ¦               +-{rsyslogd}(477)
        +-dbus-daemon(480)
        +-bluetoothd(599)
        +-avahi-daemon(627)---avahi-daemon(629)
        +-cupsd(793)
        +-upstart-socket-(803)
        +-modem-manager(834)
        +-NetworkManager(905)---{NetworkManager}(906)
        ¦                     +-{NetworkManager}(913)
        ¦                     +-{NetworkManager}(946)
        ¦                     +-dnsmasq(1199)
        ¦                     +-dhclient(18540)
        +-colord(911)---{colord}(927)
        +-polkitd(915)---{polkitd}(919)
        +-cups-browsed(924)
        +-getty(970)
        +-getty(975)
        +-getty(1014)
        +-getty(1015)
        +-getty(1019)
        +-acpid(1035)
        +-cron(1063)
        +-lightdm(1086)---{lightdm}(1101)
        ¦               +-{lightdm}(1102)
        ¦               +-Xorg(6920)
        ¦               +-lightdm(7011)---{lightdm}(7078)
        ¦                               +-gnome-session(7127)---ssh-agent(7173)
        ¦                                                     +-{gnome-session}+
        ¦                                                     +-{gnome-session}+
        ¦                                                     +-{gnome-session}+
        ¦                                                     +-gnome-settings-+
        ¦                                                     +-nautilus(7239)-+++
        ¦                                                     ¦                +++
        ¦                                                     ¦                +++
        ¦                                                     +-polkit-gnome-au+
        ¦                                                     +-nm-applet(7247)+++
        ¦                                                     +-gnome-fallback-+
        ¦                                                     +-telepathy-indic+
        ¦                                                     +-gnome-screensav+
        ¦                                                     +-update-notifier+
        ¦                                                     +-deja-dup-monito+
        ¦                                                     +-compiz(14575)--+++
        ¦                                                                     ++++
        ¦                                                                     ++++
        +-whoopsie(1236)---{whoopsie}(1243)
        ¦                +-{whoopsie}(18902)
        +-vmware-vmblock-(1237)---{vmware-vmblock-}(1240)
        ¦                       +-{vmware-vmblock-}(1241)
        ¦                       +-{vmware-vmblock-}(14130)
        +-vmtoolsd(1305)
        +-accounts-daemon(1345)---{accounts-daemon}(1350)
        ¦                       +-{accounts-daemon}(1414)
        +-tpvmlp(1382)
        +-getty(1463)
        +-console-kit-dae(1481)---{console-kit-dae}(1488)
        ¦                       +-{console-kit-dae}(1489)
        ¦                       +-{console-kit-dae}(1490)
        ¦                       +-{console-kit-dae}(1491)
        ¦                       +-{console-kit-dae}(1492)
        ¦                       +-{console-kit-dae}(1493)
        ¦                       +-{console-kit-dae}(1494)
        ¦                       +-{console-kit-dae}(1495)
        ¦                       +-{console-kit-dae}(1496)
        ¦                       +-{console-kit-dae}(1497)
        ¦                       +-{console-kit-dae}(1498)
        ¦                       +-{console-kit-dae}(1499)
        ¦                       +-{console-kit-dae}(1500)
        ¦                       +-{console-kit-dae}(1501)
        ¦                       +-{console-kit-dae}(1502)
        ¦                       +-{console-kit-dae}(1503)
        ¦                       +-{console-kit-dae}(1504)
        ¦                       +-{console-kit-dae}(1505)
        ¦                       +-{console-kit-dae}(1506)
        ¦                       +-{console-kit-dae}(1507)
        ¦                       +-{console-kit-dae}(1508)
        ¦                       +-{console-kit-dae}(1509)
        ¦                       +-{console-kit-dae}(1510)
        ¦                       +-{console-kit-dae}(1511)
        ¦                       +-{console-kit-dae}(1512)
        ¦                       +-{console-kit-dae}(1513)
        ¦                       +-{console-kit-dae}(1514)
        ¦                       +-{console-kit-dae}(1515)
        ¦                       +-{console-kit-dae}(1516)
        ¦                       +-{console-kit-dae}(1517)
        ¦                       +-{console-kit-dae}(1518)
        ¦                       +-{console-kit-dae}(1519)
        ¦                       +-{console-kit-dae}(1520)
        ¦                       +-{console-kit-dae}(1521)
        ¦                       +-{console-kit-dae}(1522)
        ¦                       +-{console-kit-dae}(1523)
        ¦                       +-{console-kit-dae}(1524)
        ¦                       +-{console-kit-dae}(1525)
        ¦                       +-{console-kit-dae}(1526)
        ¦                       +-{console-kit-dae}(1527)
        ¦                       +-{console-kit-dae}(1528)
        ¦                       +-{console-kit-dae}(1529)
        ¦                       +-{console-kit-dae}(1530)
        ¦                       +-{console-kit-dae}(1531)
        ¦                       +-{console-kit-dae}(1532)
        ¦                       +-{console-kit-dae}(1533)
        ¦                       +-{console-kit-dae}(1534)
        ¦                       +-{console-kit-dae}(1535)
        ¦                       +-{console-kit-dae}(1536)
        ¦                       +-{console-kit-dae}(1537)
        ¦                       +-{console-kit-dae}(1538)
        ¦                       +-{console-kit-dae}(1539)
        ¦                       +-{console-kit-dae}(1540)
        ¦                       +-{console-kit-dae}(1541)
        ¦                       +-{console-kit-dae}(1542)
        ¦                       +-{console-kit-dae}(1543)
        ¦                       +-{console-kit-dae}(1544)
        ¦                       +-{console-kit-dae}(1545)
        ¦                       +-{console-kit-dae}(1546)
        ¦                       +-{console-kit-dae}(1547)
        ¦                       +-{console-kit-dae}(1548)
        ¦                       +-{console-kit-dae}(1549)
        ¦                       +-{console-kit-dae}(1613)
        ¦                       +-{console-kit-dae}(1614)
        +-upowerd(1706)---{upowerd}(1707)
        ¦               +-{upowerd}(1708)
        +-rtkit-daemon(1930)---{rtkit-daemon}(1932)
        ¦                    +-{rtkit-daemon}(1933)
        +-udisksd(2171)---{udisksd}(2173)
        ¦               +-{udisksd}(2175)
        ¦               +-{udisksd}(2177)
        ¦               +-{udisksd}(2190)
        +-gnome-keyring-d(7117)---{gnome-keyring-d}(7118)
        ¦                       +-{gnome-keyring-d}(7192)
        ¦                       +-{gnome-keyring-d}(7193)
        ¦                       +-{gnome-keyring-d}(7194)
        ¦                       +-{gnome-keyring-d}(7436)
        ¦                       +-{gnome-keyring-d}(7517)
        ¦                       +-{gnome-keyring-d}(7584)
        +-dbus-launch(7176)
        +-dbus-daemon(7177)
        +-pulseaudio(7205)---{pulseaudio}(7217)
        ¦                  +-{pulseaudio}(7222)
        +-gvfsd(7210)---{gvfsd}(7211)
        +-gvfsd-fuse(7214)---{gvfsd-fuse}(7218)
        ¦                  +-{gvfsd-fuse}(7219)
        ¦                  +-{gvfsd-fuse}(7220)
        ¦                  +-{gvfsd-fuse}(7221)
        +-dconf-service(7236)---{dconf-service}(7237)
        ¦                     +-{dconf-service}(7238)
        +-gvfs-udisks2-vo(7253)---{gvfs-udisks2-vo}(7262)
        +-vmtoolsd(7254)---{vmtoolsd}(7339)
        ¦                +-{vmtoolsd}(7349)
        +-gvfs-mtp-volume(7268)---{gvfs-mtp-volume}(7271)
        +-gvfs-gphoto2-vo(7273)---{gvfs-gphoto2-vo}(7275)
        +-gvfs-afc-volume(7277)---{gvfs-afc-volume}(7278)
        ¦                       +-{gvfs-afc-volume}(7280)
        +-gconfd-2(7287)
        +-gvfsd-trash(7292)---{gvfsd-trash}(7293)
        ¦                   +-{gvfsd-trash}(7296)
        ¦                   +-{gvfsd-trash}(7302)
        ¦                   +-{gvfsd-trash}(7303)
        ¦                   +-{gvfsd-trash}(14590)
        ¦                   +-{gvfsd-trash}(14592)
        +-gvfsd-burn(7298)---{gvfsd-burn}(7299)
        ¦                  +-{gvfsd-burn}(7301)
        +-bamfdaemon(7329)---{bamfdaemon}(7335)
        ¦                  +-{bamfdaemon}(7336)
        ¦                  +-{bamfdaemon}(7338)
        +-sh(7350)---gtk-window-deco(7351)---{gtk-window-deco}(7360)
        ¦                                  +-{gtk-window-deco}(7364)
        +-unity-panel-ser(7353)---{unity-panel-ser}(7373)
        ¦                       +-{unity-panel-ser}(7374)
        +-hud-service(7355)---{hud-service}(7365)
        ¦                   +-{hud-service}(7366)
        +-indicator-sound(7378)---{indicator-sound}(7409)
        ¦                       +-{indicator-sound}(7427)
        +-indicator-sessi(7379)---{indicator-sessi}(7395)
        ¦                       +-{indicator-sessi}(7396)
        +-indicator-sync-(7382)---{indicator-sync-}(7399)
        +-indicator-print(7384)---{indicator-print}(7430)
        ¦                       +-{indicator-print}(7434)
        +-indicator-messa(7386)---{indicator-messa}(7416)
        ¦                       +-{indicator-messa}(7420)
        +-indicator-datet(7388)---{indicator-datet}(7426)
        ¦                       +-{indicator-datet}(7428)
        ¦                       +-{indicator-datet}(7429)
        +-indicator-appli(7390)---{indicator-appli}(7406)
        +-indicator-bluet(7391)---{indicator-bluet}(7417)
        ¦                       +-{indicator-bluet}(7421)
        +-evolution-sourc(7432)---{evolution-sourc}(7433)
        ¦                       +-{evolution-sourc}(7435)
        +-unity-lens-frie(7453)---{unity-lens-frie}(7469)
        ¦                       +-{unity-lens-frie}(7488)
        +-unity-files-dae(7454)---{unity-files-dae}(7470)
        ¦                       +-{unity-files-dae}(7503)
        ¦                       +-{unity-files-dae}(7595)
        +-unity-music-dae(7455)---{unity-music-dae}(7464)
        +-unity-applicati(7456)---{unity-applicati}(7475)
        ¦                       +-{unity-applicati}(7506)
        +-unity-lens-phot(7457)---{unity-lens-phot}(7558)
        ¦                       +-{unity-lens-phot}(7572)
        ¦                       +-sh(7573)---pxgsettings(7574)---{pxgsettings}(+
        ¦                       ¦                              +-{pxgsettings}(+
        ¦                       +-{unity-lens-phot}(7594)
        +-unity-shopping-(7459)---{unity-shopping-}(7479)
        ¦                       +-{unity-shopping-}(7516)
        ¦                       +-sh(7547)---pxgsettings(7549)---{pxgsettings}(+
        ¦                                                      +-{pxgsettings}(+
        +-unity-video-len(7461)---{unity-video-len}(7476)
        ¦                       +-{unity-video-len}(7524)
        +-zeitgeist-daemo(7519)---{zeitgeist-daemo}(7523)
        +-zeitgeist-fts(7542)---{zeitgeist-fts}(7545)
        ¦                     +-cat(7546)
        +-zeitgeist-datah(7543)---{zeitgeist-datah}(7551)
        ¦                       +-{zeitgeist-datah}(11120)
        +-unity-scope-vid(7579)---{unity-scope-vid}(7581)
        ¦                       +-{unity-scope-vid}(7582)
        ¦                       +-sh(7585)---pxgsettings(7586)---{pxgsettings}(+
        ¦                                                      +-{pxgsettings}(+
        +-unity-scope-gdr(7580)---{unity-scope-gdr}(7606)
        ¦                       +-{unity-scope-gdr}(7607)
        ¦                       +-{unity-scope-gdr}(7614)
        +-unity-musicstor(7616)---{unity-musicstor}(7617)
        ¦                       +-{unity-musicstor}(7618)
        +-gvfsd-http(7635)---{gvfsd-http}(7638)
        ¦                  +-{gvfsd-http}(7644)
        ¦                  +-sh(7645)---pxgsettings(7647)---{pxgsettings}(7653)
        ¦                  ¦                              +-{pxgsettings}(7657)
        ¦                  +-{gvfsd-http}(10495)
        ¦                  +-{gvfsd-http}(11147)
        +-mission-control(7727)---{mission-control}(7730)
        ¦                       +-{mission-control}(7732)
        +-ubuntuone-syncd(7758)---{ubuntuone-syncd}(7759)
        ¦                       +-{ubuntuone-syncd}(7777)
        ¦                       +-{ubuntuone-syncd}(7780)
        +-gvfsd-metadata(9684)---{gvfsd-metadata}(9692)
        +-notify-osd(9980)---{notify-osd}(9981)
        ¦                  +-{notify-osd}(9982)
        +-unity-webapps-s(10179)---{unity-webapps-s}(10183)
        ¦                        +-{unity-webapps-s}(10189)
        +-at-spi-bus-laun(10192)---{at-spi-bus-laun}(10193)
        ¦                        +-{at-spi-bus-laun}(10195)
        +-gnome-terminal(11413)---{gnome-terminal}(11417)
        ¦                       +-{gnome-terminal}(11418)
        ¦                       +-gnome-pty-helpe(11423)
        ¦                       +-bash(11424)---pstree(18906)
        ¦                       +-{gnome-terminal}(11428)
        +-update-manager(12196)---{update-manager}(12206)
                                +-{update-manager}(12208)

6. View a process by PID

advertisement
$ pstree 7542
zeitgeist-fts---cat
              +-{zeitgeist-fts}

7. Highlight the current process or any other process

Pass the -h option to highlight the current process and its ancestors. Pass -H option highlight the specified process (by name/pid):

$ pstree -h

OR highlight process with PID # 60093:

$ pstree -H 60093

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.