How to kill a process

Sooner or later you will find that an errant process is running amok or in the background and it needs to be stopped. This is called killing a process in Linux.


The most common command to kill a process is kill.

  • To kill a process, provide its PID:
$ kill 1234

By default, kill sends the TERM signal.

  • To kill multiple processes, provides all their PIDs:
$ kill 1234 5678 9999
  • Many other signals other than TERM can be sent to processes. To list all the available signal numbers and their corresponding signal names:
$ kill -L
  • To send a different signal provide the signal name:
$ kill -KILL 1234
  • The signal name can also be specified by appending a SIG as prefix:
$ kill -SIGKILL 1234
  • Alternatively, you can provide the signal number:
$ kill -9 1234
  • For most processes, sending the default TERM is enough. Most processes receive this signal, clean up their work and exit. For errant processes which do not respond to TERM, the final deathblow is sending a KILL. On sending this signal, the kernel steps in and it directly murders the process giving it no chance to clean up.


Looking up the PID of a process and then killing it is usually cumbersome. What you usually want to do is to kill based on the process name. This can be done using the killall command.

  • To kill all Vim processes:
$ killall vim
  • To kill all processes that match a regex:
$ killall -r "*abcd*"
  • By default, killall sends the TERM signal. Other signals can be sent using signal number or signal name using the same command syntax as the kill command shown above.

  • By default, killall only prints out the processes that it could not kill. It might be better to also see output from the command when it succeeds. The verbose option can be used for this:

$ killall -v vim
Killed vim(28952) with signal 15
Killed vim(28347) with signal 15
  • You might be afraid that you might kill processes by mistake with this command. If so use the interactive option to pick and choose which process to kill:
$ kill -i vim
Kill vim(1067) ? (y/N)

Tried with: Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s