killall Command in Linux: Terminate Processes by Name in Terminal
The killall command in Linux sends signals to processes and takes as a parameter not the process PID, but its name. It is generally used to terminate the execution of processes that have several child processes running at the same time.
If no specific signal is passed as a parameter, killall will send the TERM signal (15) to terminate the process gracefully.
In this example, killall forces the web server identified by the name httpd corresponding to processes 1952, 1953 and 1954 to re-read their configuration file:
$ ps aux | grep httpdwwwrun 1952 0.0 1.7 93232 2248 ? S 16:15 0:00 /usr/sbin/httpd -f /etc/httpd/httpd.confwwwrun 1953 0.0 1.7 93232 2248 ? S 16:15 0:00 /usr/sbin/httpd -f /etc/httpd/httpd.confwwwrun 1954 0.0 1.7 93232 2248 ? S 16:15 0:00 /usr/sbin/httpd -f /etc/httpd/httpd.conf# killall –HUP httpd
To abruptly terminate the web service aborting all httpd processes:
# killall –9 httpd
Difference between kill and killall
It is important that you understand the difference between the kill and killall commands. The first sends signals to one or more processes identified by PID. The second sends signals to all processes in the execution queue that have a specific name.
The signals sent by kill and killall can be passed by name or by the corresponding integer number.
The killall command is very similar to the pgrep command.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.