How To Quit Frozen Programs In Linux. Even on an operating system as reliable as Linux, sometimes there can be problems causing applications or programs to freeze.
There are several ways to kill or exit a frozen program in Linux. This article will explain how to do this.
Use the kill command
Before you can use the kill command, your system must know the process identifier (PID) of the unresponsive program.
The PID is a number that automatically identifies each process when created on any Linux OS. The advantage of this method is that it works on all Linux systems.
Find process and PID
If you don’t know which process is blocked on Linux, two tools can help you find the process: top and ps.
Top is a command-line based system monitor. At the command prompt, enter the following:
– /
$ top
The screenshot above shows a lot of information. For example, let’s say Chrome is a frozen program on your computer.
You can see that there are four instances of Chrome that work with the following PIDs:
- 3827
- 3919
- 10764
- 11679
To identify the specific instance of Chrome you want to kill, use ps command and grep to filter the output.
The command below will show you running processes related to Chrome:
ps aux | grep chrome
Kill the process
Kill Operation
You now have two pieces of information you need to kill a hung process on Linux: its name and ID. Use the commands below:
- kill – kill process by id
- killall – kill process by name
There are other signals that you can send to both commands, depending on the desired results.
For example, if you want to kill an unresponsive process and then restart it, you will use the HUP (hang up) signal.
Other kill signals include:
-
- SIGSTOP to stop the process
- SIGINT to interrupt the keyboard
- SIGKILL to kill the signal
From the above ps command, we learned that the PIDs for Chrome instances are 3827, 3919, 10764, and 11679.
To send a kill signal, run the following commands to successfully kill all four instances of Chrome:
-
-
- kill -9 3827
- kill -9 3919
- kill -9 10764
- kill -9 11679
-
You can also use one command below using killall to send the same signal:
killall -9 chrome
Click the X
Nonresponsive programs and applications usually have disabled buttons or disabled options. Sometimes it is not even possible to move the application window around the screen.
The simplest solution is to click the X button in the upper corner. Depending on your OS, the button may be in the upper left or upper right corner.
After pressing X, you will see a dialog box with two options: “Wait” or “Force Quit”. To end the program, click “Force Quit”.
Killed a Linux process on Linux using System Monitor
The default system monitor in Ubuntu is called Gnome. It gives an overview of all the processes running on Ubuntu Linux operating systems.
Users can perform a variety of tasks using a graphical user interface (GUI), including Stop, Continue, and Kill.
If your system does not include the Gnome system monitoring application, install it by following these steps. This process works for all active versions of Ubuntu Linux as well as Linux Mint and Debian.
-
-
- Use the keyboard shortcut CTRL + ALT + T in Terminal. Then use the command below to download and install the Gnome performance monitor.
-
sudo apt-get install gnome-system-monitor
-
-
- Open system monitor with a command terminal with the following:
-
gnome-system-monitor
-
-
- Or, using the GUI, go to Applications, type system monitor in the search box and click the icon to open it.
- Open in System Monitor, look in the Processes column and find the program that is not responding or is blocked, select it and right-click it.
-
You will see several options, including:
-
-
- End Process to terminate the application when clearing temporary files.
- Stop a process to pause the process so you can continue working on it later.
- Kill Process is the most extreme option that will help you exit a frozen program if the attempt to terminate it does not work.
-
Use the xkill command
Xkill is a pre-installed Ubuntu kill utility that can be used to force kill a non-responding Linux process. It is a tool that comes pre-installed in Ubuntu.
You can also install it via Terminal on other distributions using the following command:
sudo apt install xorg-xkill
Then run it by typing xkill. Your mouse will turn into a skull or cross. Left-click a frozen program to close it.
Use pgrep and pkill
Some Linux systems offer shortcuts called pkill and pgrep to perform the same tasks as kill and ps described above.
Pgrep will show the process name and ID. For example, launching pgrep chrome to view the id of the running Chrome process. Then you can use this identifier with the kill command.
pkill 7012
Or you can skip this step and use the command below to kill all instances of Chrome:
pkill chrome
This solution works well if you only have one instance of the application running. However, if you have multiple windows of the same program open and only want to kill one, use XKill instead.
When a program freezes, rebooting the system is not always the most convenient option. This is especially true if you are working on several projects at the same time and have not saved your work.
Try one of the above options as an alternative to quickly and safely exit frozen or unresponsive programs on Linux.