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 killallcan 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.
The killall command takes the following form:
killall [process name]
Replace “[process name]” with the name of any process that you wish to terminate. killall will terminate all programs that match the name specified. Without arguments,killall sends “SIGTERM“, or signal number 15, which terminates running processes that match the name specified. You may specify a different signal using the “-s” option as follows:
killall -s 9 [process name]
This sends the “SIGKILL” signal which is more successful at killing some particularly unruly processes. You may also specify signals in one of the following formats:
killall -KILL [process name] killall -SIGKILL [process name] killall -9 [process name]
The above group of commands are equivalent.
The kill command terminates individual processes as specified by their process ID numbers or “PIDs.” Commands take the following form:
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. The following examples all send the “SIGKILL” signal to the PID specified:
kill -s KILL [PID] kill -KILL [PID]
You may use kill and killall to send any of the following signals.
- SIGIO and SIGPOLL
Issue one of the following commands to get a list of all of the available signals:
kill -l killall -l
If you need to convert a signal name into a signal number, or a signal number into a signal name consider the following examples:
$ kill -l 9 KILL$ kill -l kill 9
Finding Running Processes
You may use a utility like htop </using-linux/administration-basics#monitor_processes__memory__and_cpu_usage_with_htop> or “top` to view a real time list of process and their consumption of system resources. You may also use the ps command to view processes that are currently running and their PIDs.
$ ps aux | grep "emacs" squire 3896 0.0 2.2 56600 44468 ? Ss Sep30 4:29 emacs squire 22843 0.0 0.0 3900 840 pts/11 S+ 08:49 0:00 grep emacs
This command filters the list of all processes that are currently running for the string “emacs” using grep. The number listed in the second column is the PID, which is 3896 in the case of the “emacs” process. The grep process will always match itself for a simple search, as in the second result. To view a hierarchical tree of all running processes, issue the following command:
Once you have obtained the PID or process name, use killall or kill to terminate the process as above.
Verifying Process Termination
The “-w” option to the killall command causes killall to wait until the process terminates before exiting. Consider the following command:
killall -w irssi
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:
$ killall -w irssi irssi: no process found