Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to kill a process

📅 2016-May-31 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ kill, killall, sigkill, signal, sigterm ⬩ 📚 Archive

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.

kill

The most common command to kill a process is kill.

$ kill 1234

By default, kill sends the TERM signal.

$ kill 1234 5678 9999
$ kill -L
$ kill -KILL 1234
$ kill -SIGKILL 1234
$ kill -9 1234

killall

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.

$ killall vim
$ killall -r "*abcd*"
$ killall -v vim
Killed vim(28952) with signal 15
Killed vim(28347) with signal 15
$ kill -i vim
Kill vim(1067) ? (y/N)

Tried with: Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧