Kill command with examples in Linux / Unix

Kill command with examples in Linux / Unix

In this blog we are going to see about kill command in linux. Kill command is one of the most essential linux command. The ultimate use of kill command is to kill a process. Before start killing a process let me explain what is process then we will get an idea about what we are doing.

Process is a set of instruction loaded in to memory to do a particular task. A process is associate with multiple attribute like user, PID, %CPU, %MEM, COMMAND and so on. Kill command is used to send a SIGNAL to the process. Once the process received the SIGNAL it will react according to it.We are sending SIGNAL to a process based on the process ID(PID) or process name and user.


Kill command with examples in Linux / Unix


Most frequently used SIGNALS

Signal 1, HUP – Re-read configuration files.
Signal 9, KILL – Terminate immediately,
Signal 15, TERM – Terminate cleanly,
Signal 19 STOP – To stop a process
Signal 18 CONT – To continue a process if it is stop

What is the difference between signal 9 and signal 15

The 9 signal kills a process immediately. That means it is giving a order for the process to die now with out doing any thing. It is telling the process don’t do any thing just die instantly. It is like killing a process very hardly

The signal 15 kills the process very cleanly. Very cleanly means it will flush the buffer stops all the process one by one and finally kills the process gently. The 15 signal tells do all your work properly or empty your buffer and close the process in a proper method.

The signal 15 is good and correct signal when compare to signal 9.


#kill <SIGNAL> <PID>

To terminate terminal tty1

#skill -KILL tty1

To kill a pseudo terminal

#skill -9 pts/2

To kill user rajkumar’s terminal

#skill -9 -u rajkumar

To kill a process immediately

#kill -9  2050

To kill pid 2050 and all process associated with the pid 2050

#kill -15 2050

To kill all samba process

#killall -9 smbd

To kill all apache or http process

#killall -9 httpd

To kill n number of process running with name top

#pkill -9 top

To kill all Firefox process

#pkill -9 firefox

How to stop a process

#kill -STOP 4545


#kill -19 4545

How to continue the stopped process

#kill -CONT 4545


#kill -18 4545

Describes all SIGNALS

#kill -l

The -l option will describe the name of the SIGNAL

#kill -l 1

To Describe about the SIGNAL 15

#kill -l 15

To know more about kill command kindly use the below command

#man kill
#man 7 signal

Leave a Reply

Your email address will not be published. Required fields are marked *