Use Killall and Kill Commands to Stop Processes on Linux
Updated by Linode
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.”
killall can also send specific system signals to processes. Use
kill in conjunction with tools including
ps to manage processes and end processes that have become stuck or unresponsive when necessary.
killall command takes the following form:
killall [process name]
[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,
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:
1 2 3
killall -KILL [process name] killall -SIGKILL [process name] killall -9 [process name]
The above group of commands are equivalent.
kill command terminates individual processes as specified by their process ID numbers or “PIDs.” Commands take the following form:
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
killall to send any of the following signals.
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:
1 2 3 4 5
$ kill -l 9 KILL $ kill -l kill 9
Find Running Processes
You may use a utility like 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.
1 2 3
$ ps aux | grep "emacs" username 3896 0.0 2.2 56600 44468 ? Ss Sep30 4:29 emacs username 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
kill to terminate the process as above.
Verify Process Termination
-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
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
This guide is published under a CC BY-ND 4.0 license.