Linux kill command

Updated: 12/29/2017 by Computer Hope

About kill

The kill command sends a signal to a process. If you don't specify which signal to send, by default the KILL signal is sent, which terminates the process.

This document describes the kill command, located at /bin/kill in your system. When you run kill at the command line, you may be running your shell's built-in kill instead, which may have slightly different options. For information about the built-in version of kill in the bash shell, see the bash kill built-in command.

To be sure you're using the version of kill documented here, specify the full pathname when running the command, i.e. /bin/kill.

Description

To send any signal to a process from the command line, use kill.

To list all available signals, use the -l (lowercase L) option. We've also provided a list of Linux signals for you to use as a quick reference.

Frequently-used signals include HUP, INT, KILL, STOP, CONT, and 0.

Signals may be specified in three ways:

  • by number (e.g., -9)
  • with the "SIG" prefix (e.g., -SIGKILL)
  • without "SIG" prefix (e.g., -KILL).

Specifying PID

To specify which process should receive the signal, use its numeric PID (process ID). To see a list of running processes, you can use the ps command.

Negative PID values may be used to indicate the process group ID, rather than the process ID. See the PGID column in the output of the ps command, e.g., with ps -eo user,pid,pgid,command. If you specify a process group ID as the target of a kill command, all processes in the group will receive the signal.

A PID of -1 is special. It indicates all processes except two: the kill process itself, and init (PID 1), which is the parent process of all processes on the system. Specifying -1 as the target will send the signal to all processes except these two.

Syntax

Terminate process(es):

kill pid ...

Send a signal to process(es):

kill {-signal | -s signal} pid ...

List available signals:

kill {-l | --list[=signal] | -L | --table}

Options

Option Description
-signal,
-s signal
The name, abbreviated name, or number of the signal to be sent, preceded by a dash. For example, -SIGTERM, -TERM, or -15. To view a list of available signals, use the -l or -L options (see below), or refer to our list of Linux signals.
pid A numeric process ID. If you're not sure what the PID is of a process, use the ps command to list it, e.g., ps -aux.
-l, --list[=signal] List available signal names. With -l or --list, lists all signal names. With --list=signal, translates a number into its signal name.
-L, --table List available signal names and numbers in a table.

Examples

In these examples, if a command is listed as /bin/kill, it should be run with that version of the kill command. Other commands may be run with built-in kill.

kill -9 -1

Kill all processes the user has permission to kill, except the root process (PID 1) and the kill process itself.

kill -l

List all available signal names. Sample output:

HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT
CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS
/bin/kill -l

Same as the previous command.

/bin/kill --list

Same as the previous two commands.

/bin/kill -L

List available signals and their numbers in a table format. Sample output:

 1 HUP      2 INT      3 QUIT     4 ILL      5 TRAP     6 ABRT     7 BUS
 8 FPE      9 KILL    10 USR1    11 SEGV    12 USR2    13 PIPE    14 ALRM
15 TERM    16 STKFLT  17 CHLD    18 CONT    19 STOP    20 TSTP    21 TTIN
22 TTOU    23 URG     24 XCPU    25 XFSZ    26 VTALRM  27 PROF    28 WINCH
29 POLL    30 PWR     31 SYS
/bin/kill --table

Same as the previous command.

/bin/kill --list=11

Translate signal number 11 into its signal name. Output:

SEGV
kill 123 4567

Sends the default signal (KILL, signal number 9) for the processes with IDs 123 and 4567. Those processes are terminated.

fuser — Identify processes using files or sockets.
killall — Kill processes by name.
ps — List information about running processes.