- The kill -l command will list the available signals:
$ kill -l
SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
...
- Terminate the process:
$ kill PROCESS_ID_LIST
The kill command issues a SIGTERM signal by default. The process ID list is specified with spaces for delimiters.
- The -s option specifies the signal to be sent to the process:
$ kill -s SIGNAL PID
The SIGNAL argument is either a signal name or a signal number. There are many signals available for different purposes. The most common ones are as follows:
- SIGHUP 1: Hangup detection on the death of the controlling process or terminal
- SIGINT 2: This is the signal emitted when Ctrl + C is pressed
- SIGKILL 9: This is the signal used to forcibly kill the process
- SIGTERM 15: This is the signal used to terminate a process by default
- SIGTSTP 20: This is the signal emitted when Ctrl + Z is pressed
- We frequently use force kill for processes. Use this with caution. This is an immediate action, and it will not save data or perform a normal cleanup operation. The SIGTERM signal should be tried first; SIGKILL should be saved for extreme measures:
$ kill -s SIGKILL PROCESS_ID
Alternatively, use this to perform the cleanup operation:
$ kill -9 PROCESS_ID