Kill command is a built in command in Linux which is used to terminate the process manually. This is commonly happening like, some applications may become unresponsive or start consuming a lot of system resources. In such situation the only solution is to either restart the system or kill the application process. You can terminate the process using several utilities but the kill command is most commonly used.
Make sure you are logged in as root or user with sudo privileges.
The command behavior is slightly different between the shells and the standalone
/bin/kill executable. Use the type command to display all locations on your system containing
type -a kill
kill is a shell builtin kill is /bin/kill
In the above output you can see that the shell built-in has priority over the standalone executable, and it is used whenever you type
kill. You can use the binary by typing the full path to the file
/bin/kill. Here, we are using the Bash built-in.
Following is the basic syntax for the
kill [OPTIONS] [PID]...
kill command sends a signal to specified processes or process groups, causing them to act according to the signal. When the signal is not specified, it defaults to
The most commonly used signals are:
HUP) – Reload a process.
KILL) – Kill a process.
TERM) – Gracefully stop a process.
You can get the list of all available signals, by using the
Signals can be specified in three different ways:
- Using number (e.g.,
- Using the “SIG” prefix (e.g.,
- Without the “SIG” prefix (e.g.,
Following commands are the same to each other:
kill -1 PID_NUMBER
kill -SIGHUP PID_NUMBER
kill -HUP PID_NUMBER
Terminating Processes Using the kill Command
kill a process or terminate using
kill command, first you need to find the process ID (PID). You can find PID using the different commands like
For example, to terminate the process of a chrome browser, you need to find the PID using
It will print the all process IDs of Chrome.
425 463 490 502
Once you have the process ID, you can kill them by sending the
kill -9 2551 2514 1963 1856 1771
You can combine the above commands into one, Instead of searching for PIDs and then terminating the processes:
kill -9 $(pidof chrome)
Reloading Processes Using the kill Command
kill command is also used to send the
HUP signal, which tells the processes to reload its settings.
For example, if you want to reload the Nginx server, you need to send a signal to the master process. The
nginx.pid file located at
/var/run which contains the process ID of the Nginx master process. Use the cat command to find the master PID:
Once you found the master PID reload the Nginx settings by typing:
sudo kill -1 10235
kill command is used to send a signal to processes and mostly
-9 signal is used to terminate the given processes.
If you have any questions or feedback, feel free to leave a comment.