Jul 29, 2018

Linux commands - Process

List running processes
$ ps -A
  PID TTY          TIME CMD
    1 ?        00:00:03 systemd
    2 ?        00:00:00 kthreadd
    4 ?        00:00:00 kworker/0:0H
    6 ?        00:00:00 mm_percpu_wq
    7 ?        00:00:00 ksoftirqd/0
    8 ?        00:00:00 rcu_sched
    9 ?        00:00:00 rcu_bh
   10 ?        00:00:00 migration/0
   11 ?        00:00:00 watchdog/0
   12 ?        00:00:00 cpuhp/0
 4712 ?        00:00:00 nginx
Kill a process
$ kill [signal] PID(s)

$ kill -9 3139

Signal Name  Signal Value  Behaviour
SIGHUP   1   Hangup
SIGKILL   9   Kill Signal
SIGTERM   15   Terminate
Filter process by name
$ ps aux | grep nginx

root      4712  0.0  0.1 140644  1452 ?        Ss   Jul27   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data  4714  0.0  0.4 143260  4212 ?        S    Jul27   0:00 nginx: worker process
ubuntu   11494  0.0  0.1  14856  1056 pts/0    S+   10:50   0:00 grep --color=auto nginx

$ pgrep nginx

4712
4714
Kill process by name
$ pkill nginx

$ killall nginx

0 comments: