pstree cheatsheet

The ps command in Linux has been horribly mauled by having to support Unix, BSD and GNU options and innumerable eccentric back-compatible necessities that I find it almost unusable. Instead, I like to use the pstree command for almost all my process exploration tasks. pstree shows the processes on a system as a tree.

  • Installing it is easy:
$ sudo apt install psmisc
  • By default, pstree shows the processes of all users as a tree, where each link connects the parent process on the left to the child process on the right:
$ pstree
  • To only view the processes of a particular user joe:
$ pstree joe
  • To view the command-line arguments of each process:
$ pstree -a
  • To view the PID of each process:
$ pstree -p
  • To view all the children or descendants of a process with PID 900:
$ pstree 900
  • To view both the ancestors and descendants of a process with PID 900:
$ pstree -s 900

Tried with: pstree 22.21 and Ubuntu 16.04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s