In Ubuntu, there are several methods that can be used to kill frozen applications safely and quickly without rebooting your system: xkill, system monitor utilities, and the commands kill, pkill, and killall. In this article, we will discuss these methods on a machine running Ubuntu 20.04 LTS (Focal Fossa).
Xkill is a Linux utility that allows you to kill frozen applications running on Ubuntu. It comes preinstalled in most Linux distributions, but if it is not installed on your system, you can install it as described below.
First, open the terminal using Ctrl+Alt+Del and enter the following command:
$ sudo apt install xorg-xkill
Then, provide a sudo password, and when asked for confirmation, press y, after which the system will start the installation of Xkill. After the installation is finished, xkill can be used to kill unresponsive applications.
To kill a frozen app, simply type xkill in the Terminal:
By doing so, your cursor will become an x. Simply place the x on the application you want to close and click it to close the application immediately.
You can create a keyboard shortcut for xkill by right-clicking your Ubuntu desktop and opening the Settings application.
In the Settings window, select Keyboard Shortcuts from the left pane.
Then in the right pane, click the + button, as shown in the screenshot below.
When the following dialog box appears, specify a user-friendly name for the shortcut in the Name field. Then, in the Command field, type xkill. Next, click the Set Shortcut button to select a shortcut for the xkill utility.
Use any combination of keys to set a shortcut for the xkill utility. For instance, to use Ctrl+k to launch xkill, press and hold and then press the k key. Then, release both keys.
Click the Add button to add your shortcut.
Now, whenever you need to need to kill a frozen application, you can press the shortcut keys to execute the xkill command.
Using the System Monitor
From Ubuntu System Monitor, you can also kill an application. To open System Monitor, press the super key on your keyboard and enter system monitor. When the icon for the System Monitor appears, click it to open it.
In the System Monitor application, there will be a list of processes that are currently running on the system. Select the process you want to kill and right-click it. From the menu that appears, select Kill to kill the selected process immediately.
Using kill, pkill, and killall
Kill, pkill, and killall can be called in the command line to kill an application based on its process name or process ID (PID).
To find the PID, issue the following command in the terminal:
$ ps aux | grep <process-name>
For example, in the following output, 34636 is the PID of the Rhythmbox application.
$ ps aux | grep rhythmbox
To kill a process by using its PID, use the kill command as follows:
Here, 34636 is the PID of Rhythmbox obtained above.
Alternatively, to kill a process by using its process name, you can use the pkill and killall commands. To use pkill to kill a process, type pkill followed by the process name as follows:
To use killall to kill a process, type killall followed by the process name as follows:
As you can see, there are multiple ways to kill a frozen application in Ubuntu. By using any of the above methods, you can easily kill an application that is neither responding nor terminating. Similarly, you can kill an application that is locked by another process.