kill Command: Tutorial & Examples

Send a signal to a process

The kill command is a utility in Linux that allows you to send a signal to a process, causing it to terminate or perform some other action. The signal can be specified using a signal name or signal number.

Here is the basic syntax for using kill:

kill [-s signal] pid

The pid argument is the process ID of the process that you want to send a signal to.

Here are some common signals that can be used with kill:

  • SIGHUP (1): This signal is typically used to hang up or terminate a process that is running in the background.
  • SIGINT (2): This signal is sent when the user presses CTRL+C on the keyboard. It is typically used to interrupt a process.
  • SIGKILL (9): This signal cannot be caught or ignored, and it immediately terminates the process.
  • SIGTERM (15): This signal requests that the process terminate gracefully. The process can choose to catch or ignore this signal.
  • SIGCONT (18): This signal continues a stopped process.
  • SIGSTOP (19): This signal stops the process and cannot be caught or ignored.

To send the SIGKILL signal to a process with a process ID of 123:

kill -9 123

It's worth noting that only processes that the user has permission to signal can be signaled using kill. Also, some processes may have special behavior when signaled, such as ignoring certain signals or performing some other action in response to the signal.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA