translations: [ es/Español ] · [ fr/Français ] · [ de/Deutsch ]
Table of contents
The kill
command in Linux is a powerful utility used to terminate processes running on a system. It allows users to send signals to processes, enabling the management and control of their execution.
Basic Usage
The basic usage of kill
involves terminating a process by its process ID (PID). Here’s a simple command:
kill <PID>
Replace <PID>
with the actual process ID you want to terminate. For example, to terminate a process with PID 1234, you would use:
kill 1234
By default, kill
sends the SIGTERM
signal, allowing the process to perform cleanup operations before termination.
Common Signals
kill
can send various signals to processes, altering their behavior. Some common signals include:
SIGTERM
(default signal sent bykill
) - Gracefully terminates the process.SIGKILL
- Forces immediate termination of the process without allowing cleanup.
To send a specific signal, use the -<SIGNAL>
option with kill
. For instance:
kill -9 <PID>
The -9
flag represents SIGKILL
, which forcefully terminates the process without allowing it to perform any cleanup.
Signal Names and Numbers
Signals have both names and associated numbers. While using kill
, you can use either the signal name or its number. For example:
kill -SIGTERM <PID>
or
kill -15 <PID>
Both commands send the SIGTERM
signal to the specified process.
Interactive Process Termination
In some cases, processes might not respond to termination signals. Using the -i
(interactive) option with kill
prompts the user to confirm before terminating the process:
kill -i <PID>
Created on: Dec 29, 2023