Bash kill builtin command

Updated: 05/04/2019 by Computer Hope
kill builtin bash command

On Unix-like operating systems, kill is a builtin command of the Bash shell. It sends a signal to a process.

Note

This page covers the bash builtin version of kill, which is distinct from the standalone binary executable, /bin/kill. To figure out which of these is the default kill on your system, run type kill.

Description

If no signal is specified, kill sends signal 9 (SIGTERM, terminate process).

Multiple processes may be specified, either by process ID (pid), or by job specifier (jobspec). For more information about jobs, see Job control in bash.

For more information about signals, see Signals in bash.

Syntax

To send a signal to process(es):

kill { -sigspec | -s sigspec | -n signum } {{ jobspec | pid } [ ... ] }

To list available signals, or translate a signal name or number:

kill -l [sigspec]

Options

-sigspec,
-s sigspec,
-n signum
The signal to send.

The sigspec may be a signal name or number.

The signum is a signal number.
jobspec, pid A job or process to receive the signal. Multiple jobs/processes may be listed, and they will all receive the specified signal.
-l [sigspec] List signals. If a sigspec is specified, its name is translated to its number, or vice versa. If no sigspec is specified, all available signal numbers and their names are listed.

Examples

type kill

Determine if running the kill command will execute a separate binary, or the bash built-in. (The executable /bin/kill has slightly different options; read the kill command documentation for more info.)

Example output:

kill is a shell builtin

The following seven commands all do the same thing:

kill -15 907 2331 19052
kill -TERM 907 2331 19052
kill -SIGTERM 907 2331 19052
kill -n 15 907 2331 19052
kill -s 15 907 2331 19052
kill -s TERM 907 2331 19052
kill -s SIGTERM 907 2331 19052

Each of these commands sends signal number 15 (TERM) to three processes: PIDs 907, 2331, and 19052.

kill -l SIGSTOP

Translate signal name TERM to its number. Output:

19
kill -l STOP

Same as the previous command. Output:

19
kill -l 19

Translate signal number 15 to its name. Output:

STOP
kill -l

List all available signals. Example output:

 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX

/bin/kill — Send signals to processes.