kill is used to send a signal to a process to terminate it. The signal sent by the kill command can be specified by its signal number or signal name. The default signal sent by the kill command is SIGTERM, which requests the process to terminate gracefully.
Basic Syntax
kill [signal] [pid]
Here, signal specifies the signal number or signal name to be sent to the process. If no signal is specified, SIGTERM is sent. pid specifies the process ID of the process to be terminated.
Commonly Used Signals
-
SIGTERM: This requests the process to terminate gracefully. -
SIGKILL: This forcefully terminates the process. -
SIGHUP: This hangs up the process. -
SIGSTOP: This stops the process. -
SIGCONT: This continues the stopped process.
Useful Examples
-
kill 1234: This sends the default SIGTERM signal to the process with the process ID of 1234. -
kill -9 1234: This sends the SIGKILL signal to the process with the process ID of 1234, which forcefully terminates the process. -
killall firefox: This sends the default SIGTERM signal to all the processes with the name “firefox”. -
kill -SIGHUP 1234: This sends the SIGHUP signal to the process with the process ID of 1234, which hangs up the process. -
kill -SIGSTOP 1234: This sends the SIGSTOP signal to the process with the process ID of 1234, which stops the process. -
kill -SIGCONT 1234: This sends the SIGCONT signal to the process with the process ID of 1234, which continues the stopped process.
Leave a Reply