kill

sends the specified signal (or default SIGTERM) to the specified process or process group. If you really want to kill (stop, terminate) some process, and it ignores SIGTERM (many of them do), you can try SIGKILL (-9).

kill [options] pid [...]

A signal is an asynchronous notification sent to a process or to a specific thread within the same process in order to notify it of an event that occurred.

Unix/Linux (POSIX) signals are a basic limited form of IPC (inter-process communication). Signals are simple (you can even say "primitive"), allowing for only a fixed set of names to be used and no arguments to be passed. Yet, they are widely used, sent from one process to another, or generated by the kernel.

Commands like kill and killall allow users to send signals manually - mostly to stop apps or re-read config files. The signal can be specified either with a number or with a name. Signal names have a short form (like TERM ) and a long form (like SIGTERM).

kill -l

list all available signal names and numbers;

kill -l 2

translate number 2 into a signal name;

kill %3

terminate job #3 (send SIGTERM to proc);

kill 1420

terminate proc with pid 1420 (send SIGTERM);

kill -9 9528

terminate proc with pid 9528 (send SIGKILL);

kill -KILL 9528

like prev (terminate proc ... sending SIGKILL);

kill -9 -1

kill all processes you can kill;

kill 204 690 9520

send SIGTERM to processes with the specified PIDs;

kill -HUP syslogd

force syslogd to re-read its config;

Most shells have a built-in kill function with usage similar to that of the command described here, except some options.

Note that PID can be:

 n (n > 0); the process with pid = n will be signaled;
 0 all processes in the current process group will be signaled;
-1 all processes with pid >1 will be signaled;
-n (n > 1); all processes in the process group n will be signaled; in this case the signal must be specified first (otherwise you should type -- before this arg);
cmd all processes invoked using cmd will be signaled;
Options

-h    --help    -V    --version

if these options are rejected, then you probably invoked the built-in kill (shell cmd); this description pertains to /bin/kill;

-a do not restrict cmd-to-pid conversion to processes with the same uid as the present process;

-l [signum], --list[=signum]

list all available signal names and numbers; if a signal number is specified, show signal's name;

-L, --table

list all available signals as a table;

-s signal, --signal signal

specify the signal to send (number or name);

killall

sends a signal to all processes running any of the specified cmds. If no sig is specified, SIGTERM is sent.

killall sendmail

stop all processes related to sendmail;

killall -HUP /usr/sbin/rpc.nfsd

force rpc.nfsd daemon to re-read its config files;

killall [options] [--] cmd_name ...

If cmd_name contains a '/', processes executing that particular file will be selected for termination independent of their name. ~ returns 0 if at least one process has been killed for each specified command. ~ never kills itself, but may kill other ~ processes.

Options

-V    --version    -v    --verbose

-h not listed as option (as well as --help), but works as supposed;
-e require an exact match for long names (--exact);
-g kill process group to which process belongs (--process-group);
-I use case insensitive process name matching (--ignore-case);
-i ask for confirmation before killing (--interactive);
-l list all known signal names (--list);

-o time, --older-than time

kill only processes older than the specified time;

-q do not complain if no processes were killed (--quiet);
-r interpret cmd_name as an extended regex (--regexp);

-s signame, --signal signame

send the specified signame instead of SIGTERM;

-u username, --user username

kill only process(es) running as username;

-w wait for all killed processes to die (it checks once per second and returns only when all processes have terminated; thus, it may wait forever if the signal was ignored, had no effect, or if the process is in zombie state) (--wait);

-y time, --younger-than time

kill only processes younger than the specified time;