Skip to content

Instantly share code, notes, and snippets.

@gmacario
Last active October 4, 2022 12:32
Show Gist options
  • Save gmacario/b0de9e73132ae333e4ee to your computer and use it in GitHub Desktop.
Save gmacario/b0de9e73132ae333e4ee to your computer and use it in GitHub Desktop.

Credits:

$ htop

Type '>' then select "CPU" to sort entries by CPU usage

Identify pid of those using most CPU (in our case: 3884, 6360, 8738)

$ ps -p 3884,6360,8738

Displaying help

$ man ps
$ ps --help
$ ps --help simple
$ ps --help list
$ ps --help output
$ ps --help threads
$ ps --help misc
$ ps --help all

All processes

$ ps -A

All processes of uid 1002

$ ps -u 1002

To see every process on the system

$ ps -e
$ ps -ef
$ ps -eF
$ ps -ely

To print a process tree

$ ps -ejH

To get security info:

$ ps -eo euser,ruser,suser,fuser,f,comm,label
$ ps -eM
$ ps -ejH   # equivalent to "ps aux"
$ ps -a -o pid,ppid,stat,comm

Print only the name of process id 42

$ ps -p 42 -o comm=

List only processes with id

$ pstree -ap

...

  │   │   ├─sh,2894 -xe /tmp/hudson2638352890419120329.sh
  │   │   │   └─bash,2895 -xec source init.sh && bitbake genivi-demo-platform
  │   │   │       └─python,3246 /home/jenkins/workspace/compile-gdp/poky/bitbake/bin/bitbake ...
  │   │   │           └─python,3248 /home/jenkins/workspace/compile-gdp/poky/bitbake/bin/bitbake ...
  │   │   │               ├─pseudo,19194bitbake-wo
  │   │   │               │   └─python,19203 ...
  │   │   │               ├─python,3317 ...
  │   │   │               │   └─python,3319 ...
  │   │   │               │       └─run.do_configur,3321...
  │   │   │               │           └─bash,19951...
  │   │   │               │               └─bash,3399...
  │   │   │               │                   └─bash,3882...
  │   │   │               │                       └─(java,3883)
  │   │   │               │                           └─{java},3884
  │   │   │               └─{python},3249
  │   │   ├─(try,5335)

Send hangup signal to pid 3882

$ sudo kill -HUP 3882
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment