Friday, June 5, 2015

How to Kill Linux Processes/Unresponsive Applications Using 'kill & pkill' Command

How to Kill Linux Processes/Unresponsive Applications Using 'kill & pkill' Command

kill process in linux

How do we kill a resource/process in Linux?

Obviously we find the PID of the resource and then pass the PID to the kill command. Speaking more accurately, we can find PID of a resource (say firefox) as:

Syntax :

ps -A | grep -i process name


ps -A | grep -i firefox


alternatively we can use pgrep command to find PID

Syntax :

pgrep process name


pgrep firefox

sample output:

sample output image not displyed

In the above output, the number '2697' is the PID of process (firefox), use the kill command to kill the process as shown below.

Syntax :

kill PID OR kill -signalName PID OR kill -signalNumber PID


  1. signalNumber : A non-negative decimal integer, specifying the signal to be sent instead of the default TERM.
  2. signalName : A symbolic signal name specifying the signal to be sent instead of the default TERM.


kill 2697

The kill command sends a signal to a process, whose PID is passed along with the command.

0SIGNULL (NULL)NullCheck access to pid
1SIGHUP (HUP)HangupTerminate; can be trapped
2SIGINT (INT)InterruptTerminate; can be trapped
3SIGQUIT (QUIT)QuitTerminate with core dump; can be trapped
9SIGKILL (KILL)KillForced termination; cannot be trapped
15SIGTERM (TERM)TerminateTerminate; can be trapped
24SIGSTOP (STOP)StopPause the process; cannot be trapped. This is default if signal not provided to kill command.
25SIGTSTP (STP)TerminalStop/pause the process; can be trapped
26SIGCONT (CONT)ContinueRun a stopped process

Alternatively, we can use pkill command, which kills a process based upon name and other attributes of a process. To kill a process say whose name is firefox, we need to execute:

Syntax :

pkill process name


pkill firefox

Forced Killing (SIGKILL or kill -9)

The kill command has a misleading name because it does not actually kill processes. Rather, it sends signals to them. Each process is supplied with a set of standard signal handlers by the operating system in order to deal with incoming signals. When no signal is explicitly included in the command, signal 15, named SIGTERM, is sent by default. If this fails, the stronger signal 9, called SIGKILL, should be used. For example, the following command would nearly guarantee that process 485 would be killed:

Syntax :

kill -9 PID OR pkill -9 process name

kill -9 2697 OR pkill -9 firefox

The only situation in which signal 9 will fail is if the process is in the midst of making a system call, which is a request to the kernel (i.e., the core of the operating system) for some action such as process creation. In this situation, the process will die once it has returned from the system call.

To list the signal names, pass the -l option as follows:

There are more than 60 signals that can be used with kill, but, fortunately, most users will only need to be aware of signal 9. The full list is contained in the file /usr/include/linux/signal.h and can be viewed by using kill with its -l option, i.e.,

kill -l