kill command Examples

The kill command can send all of the above signals to commands and process. However, commands only give response if they are programmed to recognize those signals. Particularly useful signals include:

SIGHUP (1) - Hangup detected on controlling terminal or death of controlling process.

SIGINT (2) - Interrupt from keyboard.

SIGKILL (9) - Kill signal i.e. kill running process.

SIGSTOP (19) - Stop process.

SIGCONT (18) - Continue process if stopped.

To send a kill signal to PID # 1234 use:

kill-91234

OR

kill-KILL1234

OR

kill-SIGKILL1234

killall - kill processes by name

killall sends a signal to all processes running any of the specified commands . If no signal name is specified, SIGTERM is sent. To terminate all firefox process (child and parent), enter:

killall processName
killall firefox-bin

To send a KILL signal to firefox, enter:

killall-s SIGKILL firefox-bin

pkill - kill process

The pkill command is another command with additional options to kill process by its name, user name, group name, terminal, UID, EUID, and GID. It will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout. To send a kill signal to php-cgi process, enter:

pkill -KILL php-cgi

The above example will kill all users php-cgi process. However, -u option will kill only processes whose effective user ID is set to vivek: