When we operate and maintain the server, if we need to terminate a process, we will use the kill command, but we cannot misuse it to cause server failure. Record the common usage of the kill command in this article.
Basic usage:
kill [signal] PID
Common usage:
1 (SIGHUP): Terminates the process, which is often used to reload the configuration file. 9 (SIGKILL): Force the process to terminate. 15 (SIGTERM): Requests the process to terminate, allowing the process to clean up resources.
Common cases:
Terminate a process:
kill 12345
Use SIGKILL signal to forcibly terminate the process:
kill -9 12345
Terminate process by process name:
pkill firefox
To use kill
To terminate or terminate a process, you need to find the process ID number (PID) first. To do this, you can use different commands, such as top
, ps
, pidof
and pgrep
。