Definition of Linux Kill Signals
The way of communicating a message from one process to another process is called a signal. The message that we try to communicate is also called notification that the destination process is to be processed. They might ignore the signals or leave to perform the default action. The kill command in Linux will allow users in sending a signal to the process. When we use the signal command to send a signal to a process that is owned by other users (like root), then we would need admin rights and have the privilege to use the ‘sudo’ command.
Syntax:
Kill signal command in Linux does not only use to stop processes running in the Linux system, but also used to terminate the software from all illegal programs. Thus, few of the kill command signals in Linux are a part of security parameters. Remarkably, these kill commands do not only terminate or kill the programs but also they are used to pause, restart, or continue the programs.
The Basic syntax of Kill Signal command in Linux is :
kill -signal -pid
Here signal can be either the signal name or number of the signal used to send to the process and pid is the process_ID.
To get the list of signals supported in the Linux server, we can use the below command:
kill -l
Here -l will list out all the signals that are supported in Linux. This command will list the signal names. The output of the command will display as below:
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
How to Kill Signals in Linux?
Here are the common signals that we generally use in Linux.
Signal Name | Signal Number | Description |
SIGINT | 2 | Signals when the Linux user presses ‘CONTROL-C’ |
SIGHUP | 1 | Hangs up signals when controlling the terminal or at the end of the controlling processes. |
SIGQUIT | 3 | Signals when the Linux user presses ‘CONTROL-D’ |
SIGFPE | 8 | Signals when any unexpected mathematical operation is performed. |
SIGKILL | 9 | When any of the process issues this signal, it will quit immediately. |
SIGALRM | 14 | Signals for alarm clock |
SIGTERM | 15 | Signals to terminate the process or the software. |
SIGSTOP | 17,19,23 | Signals to stop the process in Linux. |
Examples
There are many ways to send signals to a program in Linux. A few of them are explained below:
-
Option SIGINT:
The most common way to kill a process in Linux is by using ‘CONTROL-C’, when we press ‘CONTROL-C’ SIGINT signal is sent to the program and by default, the program terminates. The signal SIGINT is also called a Interrupt signal or key.
-
Option SIGKILL:
This Command is used to kill a process by taking the signal name and PID is given by the user in Linux.
Syntax: kill -9 5653
Command: kill -SIGKILL 5653
Example: Here we will kill the process id 5653 by using -SIGKILL command.
-
Option killall:
This command kills the process with its name. We should be particularly killing the process by using its name. For example, if any process is running for a long time and the Linux user has no idea on the process id, then we can kill the process by its process name.
Syntax: killall -SIGKILL pname
Command: killall -SIGKILL tez
Example: Here particular process whose name is ‘tez’ is been killed in Linux. This command is generally used when we are not assured about the process id (PID).
-
Option pkill:
The command ‘pkill’ is more likely to killall command except that it will allow using partial process_names. For example, if there are many processes whose names are partial common, we can kill all of them using pkill command. We can also kill users with this command.
Syntax: pkill -9 process_name
pkill -9 -u username
Command: pkill -9 tez
pkill -9 -u root
Example: Here all the processes are killed whose names are partially common to process ‘tez’.
List of Linux Kill Signals
Below are the list of Signals and their descriptions:
- SIGTRAP – The main purpose of SIGTRAP command signal is to debug a process. When a signal is sent to a process and it is waiting for an action or condition to meet the debugger then this signal will be sent.
- SIGABRT – This SIGABRT kill signal is used for aborting the processing signal. Basically, a process is initiated to SIGABRT to kill the signal on its own.
- SIGBUS – Whenever a program sends the SIGBUS signal, it happens to be caused by a bus error. Generally, the bus errors are because of a program that tries to utilize duplicate physical addresses or it might be due to the program that may have its memory settings that is set incorrectly.
- SIGCHLD – Whenever a parent program does not find its child process, then the parent program sends the SIGCHLD signal. This is used to clear up the resources which are used by the child program.
- SIGPROF – Whenever any process is using CPU Time then the SIGPROF signal is sent by the system when the program is elapsing.
- SIGPOLL – Whenever a program is causing any non-concurrent I/O actions, then that program will send the SIGPOLL signal.
Conclusion
Kill signal command in Linux does not only use to stop processes running in the Linux system, but also used to terminate the software from all illegal programs. Thus, few of the kill command signals in Linux are a part of security parameters. Remarkably, these kill commands does not only terminate or kill the programs but also they are used to pause, restart, or continue the programs.
In the above article, we have shown how to use the kill command to send signals to the processes in Linux Server. Syntaxes and examples are given in the article for a better understanding of the user.
Recommended Articles
This is a guide to Linux Kill Signals. Here we discuss the introduction, how to Kill Signals in Linux with examples respectively. You may also have a look at the following articles to learn more –
16 Online Courses | 3 Hands-on Projects | 160+ Hours | Verifiable Certificate of Completion
4.5
View Course
Related Courses