How to kill process in Linux with examples

To kill a process we use kill command, kill command sends a signal to process. To kill a process you must know process name or process ID. There two command which can be used to kill a program –  kill and killall.

Syntax

kill signal PID

Example

kill -9 3726

kill SIGTERM 3726

It should be noted that all user cannot kill all processes. A user can kill only process process belonging to himself. But a user cannot kill processes belonging to other user or system level processes. A root user can kill processes belonging to other user or system level processes.

Below table has details about signal and their effect.

SIgnal Name Signal Value Signal effect
SIGNUP 1 Hangup
SIGKILL 9 Kill Signal
SIGTERM 15 Terminate

SIGHUP is safest way to kill an application , after closing an process it reloads it along with configuration file and open and closes log file. SIGKILL closes process without saving anything and most unsafe of three. SIGNTERM may kill application immediately some applications may stop and some may not.

Kill multiple process

You can use kill command to kill multiple process in one go.

Syntax

kill  signal PID1 PID2 PID3

Example

kill -9 3726 3789 4082

kill SIGTERM 3726 3789 4082

Kill multiple instance of process

Several command like chrome may have multiple instances running in system. To kill all instance of a process use command killall

Syntax

killall  signal process_name

Example

killall -9 chrome

kill SIGTERM chrome

This will kill all running instance of chrome process.