kill unresponsive process in linux

How to Kill Unresponsive Process in Linux

Sometimes our applications & services stop working or responding in Linux due to bug or some other reason. In such cases, you may need to stop them in order to recover your system back to normalcy. Otherwise, it may freeze your system. There are many simple ways to close applications & services that have stopped responding. You can do this by killing unresponsive process responsible for that application/task. In this article, we will look at the different ways to kill unresponsive process in Linux.


How to Kill Unresponsive Process in Linux

Here are the different ways to kill unresponsive process in Linux. They can be used to kill desktop applications, background processes as well as terminal processes, If your process is running on terminal and it stops responding, open another terminal window and run the following commands. On some systems, you may need root or sudo privileges to be able to kill processes of other users. However, you will always be able to kill processes if you are its owner.


1. Using kill command

In this case, we use ps command to get list all running processes, pass its output to grep to get the PID (process ID) of unresponsive process. Then we use kill command to kill it.

Here is an example to kill application ‘firefox’ which has stopped responding.

$ sudo ps aux| grep firefox
root      3142  0.0  1.8 594956 37624 ?        Ss   Aug02   0:12 /usr/sbin/firefox
www-data  9935  0.0  4.4 976264 91080 ?        S    Aug05   0:53 /usr/sbin/apache2 -k start

The second column above displays PID of firefox process. Kill this process with kill command.

$ sudo kill 3142

You can also use pgrep command followed by application name, to directly get the PID of your desired process.

$ pgrep firefox
3142
$ sudo kill 3142


2. Using pkill command

You may also use pkill command to do what we did above, that is, find the PID of unresponsive process and kill it.

$ sudo pkill application_name

Here is an example to kill firefox process

$ sudo pkill firefox

The above command will kill all processes that contains the string “firefox” in its command. So use it only when you are sure you want to kill processes this way. Otherwise, it is always advisable to get the list of running processes using ps command and selectively kill processes based on your requirement.


3. Using killall

If you have too many instances of process and find it tedious to kill them one by one, then use killall command followed by process name. It will kill all instances of given application.

$ killall application_name

Here is an example to kill all instances of firefox process.

$ killall firefox


4. Using xkill

If you have one or more unresponsive windows open and you need to kill any of them, open terminal and use the xkill command

$ xkill

When you run the above command, the cursor will change shape to X mark and ask you to click the window that you want to close.

Select the window whose client you wish to kill with button 1...

When you click any of the windows, Linux will close that window and display a message in your open terminal.

xkill : killing creator of resource ....

That’s it. In this article, we have looked at different ways to kill processes whether they are running in desktop, terminal or background. The key is to get PID of unresponsive process and issue kill or another command to kill it.

Also read:

How to Lock User After Failed Login Attempts in Linux
How to Find Failed Login Attempts in Linux
How to Schedule Shutdown in Ubuntu Linux
How to Secure SSH Server on Your System
How to Create Shared Folders in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *