← Full reference

kill

Send a signal to a process — terminate it gracefully, kill it, reload its config, pause it

kill doesn't necessarily kill — it sends a signal to a process by PID. What happens next is up to the process: most signals can be caught or ignored. By default TERM is sent — a request to exit.

Syntax

kill [-signal] PID…
kill -s signal PID…
kill -l [number]

The signal can be given by name with or without the SIG prefix, or by number: kill -TERM, kill -SIGTERM, kill -15, kill -s TERM are all the same.

Options

OptionWhat it does
-SIGNAL / -Nwhich signal to send (default TERM)
-s SIGNALthe same, as a separate argument
-llist of signals; kill -l 15 → TERM, kill -l 137 → KILL (translates the 128+N code)
-La table of signals (/bin/kill only)
-0send nothing, just check: the process exists and you're allowed to signal it
%1instead of a PID — a shell job number (jobs)
-- -PGIDa negative number — signal the whole process group

kill is usually a bash builtin; there's also a standalone program /bin/kill from procps with the same main options.

Signals

Signal#Default actionWhen it's used
HUP1terminatethe terminal closed; many daemons (nginx, sshd) reload their config on HUP
INT2terminatewhat Ctrl+C sends
QUIT3terminate with a core dumpCtrl+\
KILL9kill immediatelythe last resort: can't be caught or ignored
USR1 / USR210 / 12terminateup to the program: reopen logs, print statistics
PIPE13terminatewriting to a closed pipe (yes | head)
TERM15terminatea polite request to exit, the default signal; the program can clean up
CHLD17ignorea child process exited
CONT18continueresume a stopped process
STOP19stopfreeze a process; can't be caught
TSTP20stopCtrl+Z; unlike STOP, can be caught

The numbers are for Linux on x86_64 and ARM; some differ on other architectures, so names are more reliable in scripts. A process killed by signal N exits with code 128+N: TERM → 143, KILL → 137, INT → 130.

Examples

# politely terminate a process
kill 1234

# if that didn't help after a few seconds — kill it
kill -9 1234

# reload a daemon's configuration without restarting it
kill -HUP "$(cat /run/nginx.pid)"

# pause and resume
kill -STOP 1234
kill -CONT 1234

# is the process alive (sends nothing)
if kill -0 1234 2>/dev/null; then echo "running"; fi

# which signal is behind code 137
kill -l 137                              # KILL

# a shell background job
sleep 100 &
kill %1

# PID of the last background process and its code after it exits
sleep 100 & pid=$!
kill "$pid"; wait "$pid"; echo $?        # 143

# the whole process group (e.g. a script and its children)
kill -TERM -- -4321

Pitfalls

  • Don't start with -9. KILL doesn't let the process close files, delete its PID file and locks, or flush buffers. TERM first, wait, and only then KILL.
  • kill kills only the given process, not its children. The children are orphaned and reparented to PID 1. To hit all of them, signal the group: kill -- -PGID.
  • A process in state D doesn't react even to KILL until it returns from the kernel (usually it's waiting on a disk or NFS). A zombie (Z) can't be killed at all — it has already exited.
  • A process can ignore a signal. trap '' TERM in a script, and kill does nothing. To see the mask of ignored signals: the SigIgn line in /proc/<pid>/status.
  • Background processes started from a script ignore INT and QUIT (bash does this when job control is off). Send them TERM.
  • A PID can change owners. Between ps and kill the process may have exited and its number gone to another one. Kill by a fresh PID or via pkill with an exact pattern.
  • kill -0 also returns an error for someone else's process if you lack permissions — that doesn't mean the process doesn't exist.
  • killall isn't installed in the image; to kill by name use pkill.

See also

pgrep · ps · exit-codes · service