How to Kill a process in Linux

Share it:


kill is the command used to terminate the  process,the kill command can be internal as part of modern shell  or it will be located in /bin/kill

The basic syntax to kill the process is the kill command followed by the PID

1.kill - TERM <PID>
2. killall <Process name>


PID 

 
PID is nothing but the process identification number , that is automatically assigned to each process when it is created.
 

The below example shows the running process and their pid's

[[email protected] ~]# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.3  1.3  52848  6612 ?        Ss   05:17   0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 23
root         2  0.0  0.0      0     0 ?        S    05:17   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    05:17   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   05:17   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        S    05:17   0:00 [kworker/u2:0]
root         7  0.0  0.0      0     0 ?        S    05:17   0:00 [migration/0]
root         8  0.0  0.0      0     0 ?        S    05:17   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    05:17   0:00 [rcuob/0]


Examples:

[[email protected] ~]# ps aux  | grep firefox
root       759  0.0  0.6 299172  3216 ?        Ssl  05:17   0:00 /usr/lib/firefox-3.5.3/firefox

[[email protected] ~]# kill 759
[[email protected] ~]#

[[email protected] ~]# killall -9 firefox
[[email protected] ~]# psg aux | grep firefox

Share it:

Post A Comment: