LinuxCommandLibrary

kill

Terminate processes

TLDR

Terminate a program using the default SIGTERM (terminate) signal

$ kill [process_id]
copy

List available signal names (to be used without the SIG prefix)
$ kill -l
copy

Terminate a program using the SIGHUP (hang up) signal. Many daemons will reload instead of terminating
$ kill -[1|HUP] [process_id]
copy

Terminate a program using the SIGINT (interrupt) signal. This is typically initiated by the user pressing
$ kill -[2|INT] [process_id]
copy

Signal the operating system to immediately terminate a program (which gets no chance to capture the signal)
$ kill -[9|KILL] [process_id]
copy

Signal the operating system to pause a program until a SIGCONT ("continue") signal is received
$ kill -[17|STOP] [process_id]
copy

Send a SIGUSR1 signal to all processes with the given GID (group id)
$ kill -[SIGUSR1] -[group_id]
copy

SYNOPSIS

kill [-signal | -s signal] pid ...
kill -l [number]
kill -L

PARAMETERS

-a, --all
    Do not restrict targets by user or PID namespace

-l, --list [number]
    List signal names, or convert number to name

-L, --table
    List signals in table format with descriptions

-p, --pid
    Print PIDs of matching processes without signaling

-s signal, --signal signal, -signal
    Specify signal by name or number

-Q, --queue signal
    Use sigqueue(2) to send signal with data

-n pid, --ns pid
    Send signal within specified PID namespace

DESCRIPTION

The kill command is a fundamental Linux utility for sending signals to processes, identified by their process ID (PID). By default, it transmits the SIGTERM signal (signal 15), which politely requests a process to terminate, allowing it to perform cleanup tasks like saving data or closing files. Users can specify alternative signals using names (e.g., SIGKILL) or numbers (e.g., -9), enabling actions from reloads to forceful termination.

Processes can be targeted individually by PID, multiple PIDs, or job control specifications like %1 for jobs managed by the shell. This makes kill essential for process management in scripts, debugging, and system administration. It interacts with the kernel via the kill(2) system call, respecting user permissions—only the owner, root, or process itself can typically send signals.

Common use cases include gracefully stopping services (kill PID) or force-killing unresponsive applications (kill -9 PID). The -l option lists available signals, aiding users in selecting the appropriate one. While powerful, misuse can lead to data loss or system instability, emphasizing the need for caution.

CAVEATS

SIGKILL (-9) cannot be caught or ignored, causing abrupt termination without cleanup; prefer SIGTERM first.
Permission denied if not process owner or root.
No process name matching—use pkill(1) instead.

COMMON SIGNALS

SIGTERM (15): Graceful termination (default)
SIGKILL (9): Force kill
SIGHUP (1): Reload config
SIGINT (2): Interrupt
SIGUSR1/2 (10/12): User-defined

EXAMPLES

kill 1234: Terminate PID 1234 gracefully
kill -9 1234: Force kill
kill -l: List signals
kill %1: Kill job 1

HISTORY

Originated in Version 7 Unix (1979); POSIX.1-2008 standardized. GNU coreutils version adds options like --table since 1990s.

SEE ALSO

pkill(1), pgrep(1), killall(1), pidof(1)

Copied to clipboard