In this article we are going to show you that how to kill a process in Linux operating system using kill
, killall
, and pkill
commands. If you want to learn about terminate a process in Linux then this post is ideal for you.
The kill
command terminates processes using Process ID number (PID), while the killall
and pkill
commands terminate running processes using their names and other attributes.
Linux is an operating system, like Windows OS, iOS, and Mac OS. It is one of the most popular operating system on the planet, Android is also powered by Linux OS(operating system). An operating system is software that manages all hardware resources associated with desktop or laptop. In simple words, the OS(operating system) manages communication between software and hardware.
Linux OS(operating system) is also distributed under an open source license. Open source following these points :
- Freely to run the program, for any purpose.
- Free to study how the program works.
- Freely to re-distribute copies so you can help your friends.
- Free to distribute copies of your modified versions to others.
How to Kill a Process in Linux
Follow bellow steps to terminate unresponsive and unexpectedly crashed process:
System Kill Signals
When you run kill
, killall
, and pkill
command then they will sends a given signal to specified processes or process groups and when no signal is specified, each tool sends 15
(TERM
).
Below are the most commonly used signals in Linux :
1
(HUP
): it is used to reload a process.9
(KILL
): it is used to kill a process.15
(TERM
): it is used to gracefully stop a process.
These signals are specified in three different ways:
- using a number (e.g. -1)
- with the “SIG” prefix (e.g. -SIGHUP)
- without the “SIG” prefix (e.g. -HUP)
You can list of all available signals in the Linux using kill -l
option with kill command.
$ kill -l # or killall -l
Terminate Process Using kill Command
Before terminate a process with the kill
command, you will need to find the process PID of a running process. You can find PID using different commands such as top
, ps
, pidof
, and pgrep
.
For an example, if Google Chrome browser is become unresponsive and you want to kill the browser process then first find the PID of Google Chrome using the pidof command:
$ pidof google-chrome
The above command will display the all Google Chrome processes:
Output
5561 2021 1992 1685
After find the Google Chrome processes PIDs, terminate all of them using command below:
$ kill -9 5561 2021 1992 1685
Terminate Process Using killall Command
The killall
command terminate running programs or processes using their names and other attributes.
To terminate a running program, run the command below:
$ killall -9 google-chrome
The command above terminates all programs that match by given name.
Using the The killall
command, you can also terminate all processes that are running as a user studiesonline
. To do that simply run the command below:
sudo killall -u studiesonline
Terminate Process Using pkill Command
The pkill
command also terminate running programs or processes using their names and other attributes.
To terminate a running program, run the command below:
$ pkill -9 google-chrome
The command above terminates all programs that match by given name.
The pkill
command also send a signal to processes that are owned by a given user.
To kill only the chrome processes that are owned by the user studiesonline, run the command below:
$ pkill -9 -u studiesonline google-chrome
That’s all.
If you face any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.