Kill command on Linux (send signals) [Basic Guide]

The kill command in Linux sends signals to processes.

It is generally used to terminate the execution of processes identified by your PID.

If no specific signal is passed as a parameter, kill will send the SIGTERM (15) signal to end the process in an elegant manner.

In this example the kill forces the web server identified by PID 1953 to read its configuration file again:

$ ps aux | grep httpd 
wwwrun 1952 0.0 1.7 93232 2248? At 16:15 0:00 /usr/sbin/httpd -f /etc/httpd/httpd.conf
wwwrun 1953 0.0 1.7 93232 2248? At 16:15 0:00 /usr/sbin/httpd -f /etc/httpd/httpd.conf
wwwrun 1954 0.0 1.7 93232 2248? At 16:15 0:00 /usr/sbin/httpd -f /etc/httpd/httpd.conf
# kill —HUP 1953

It abruptly terminates the web service processes with the 1953 and 1954 PIDs:

# kill —9 1953 1954

Kill’s -l option provides a list of signals and their respective codes:

$ kill -l
1) SIGHUP 2) SIGNING 3) SIGQUIT 4) SEAL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
(...)

A command that makes it easy to send signals to processes that have several child processes is killall.

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Need help?