How to kill processes on Linux with “kill” and “killall” February 2, 2011Posted by Tournas Dimitrios in Linux.
On Linux there are plenty of ways to get rid of an application that refuses to listen to the File > Exit or File > Quit or that handy X button in the upper right corner . When you’ve exhausted all of your options, there is always the command line. Windows users are also very familiar with the “ctl+alt+del” functionality, but we are passionate Linux users right ?
For taking care of ” stubborn ” Linux applications, there are two very helpful commands: kill and killall. But how are they used? Are they complicated or are they simple? Let’s examine these two very handy commands (they are installed by default on all Linux distributions ) .
killall is a tool for ending running processes on your system based on name. In contrast, kill terminates processes based on process ID number or “PID.” kill and killall can also send specific system signals to processes. Use killall and kill in conjunction with tools including ps to manage processes and end processes that have become stuck or unresponsive when necessary.
That’s all the theory for these commands , let’s get directly to practical examples ..
|killall -9 firefox-bin||The obvious problem with this is you must know the exact name of the process you want to kill. So if you don’t know the name you can go back ps aux|grep firefox to get the exact name of the process.|
|kill [PID]||The kill command terminates individual processes as specified by their process ID numbers or “PIDs.”
This sends “SIGTERM” to the PID specified .You may specify multiple PIDs on the command line to terminate processes with “kill“
||You may also send alternate system signals with kill. These examples all send the “SIGKILL” signal to the PID specified .|
||These group of commands are equivalent.|
|killall -w irssi||The “-w” option to the killall command causes killall to wait until the process terminates before exiting. Consider the following command .This command issues the “SIGTERM” system signal to the process with a name that matches “irssi“.“killall“ will wait until the matched processes have ended. If no process matches the name specified, killall returns an error message, as below:|
||Issue one of the following commands to get a list of all of the available signals|
Alternative solutions :
- The terminal based ” top ” command
- The gnome Gui based app : gnome-system-monitor