Linux-based operating systems are deemed to be more stable than other operating systems. Testimony to this is the fact that Linux powers over 95% of supercomputers in the world. However, stability and performance doesn’t mean that Linux systems don’t experience app or OS freezes.
There could be many different types of freezes such as situations where one or more applications freeze, the mouse stops responding along with applications, and finally, where everything (including the keyboard) freezes. In this article we will discuss in detail the various solutions available for each case and in what order you should apply them.
Note: All the solutions/techniques mentioned in this article have been tested on Ubuntu (version 16.04). They may, or may not, work on other distributions.
When an application freezes, the first and most obvious step is to close the app by clicking the close button (circular-shaped button with ‘x’ inside it) located at the top-left of the application window. Usually, in case of a freeze, when you do this, a small window box pops up saying that the application is not responding, giving you an option to either kill the process or wait for the application to respond.
You can click the “Force Quit” button to get rid of the application. However, if this doesn’t work, the next step should be to run the
xkill command on the command line terminal. (You can also create a keyboard shortcut for it.) As soon as the command is run, your mouse pointer will turn into an X.
Now, in this state, doing a left mouse click on any application window will kill that application.
While “xkill” is an excellent solution to get rid of frozen apps, you can’t use this technique on the processes/applications that do not have a GUI. Worry not, as we already have some commonly-known solutions like sending a SIGINT signal to the application/process by pressing “Ctrl + C” or killing the process using the
When the mouse stops working as well
What if your mouse freezes as well? In that case the most convenient option is to grab hold of a command line terminal, which you can launch by pressing “Alt + F2”, entering
gnome-terminal, and then pressing Enter.
Needless to say, once you are on the command line, you can easily kill a process/application, irrespective of whether or not it’s GUI-based.
If for some reason the above solution doesn’t work, you can switch to a virtual terminal by pressing “Alt + Ctrl + F1.” Once there, just enter your login details, and you now have command line access to your system. When you are done with killing unresponsive processes, you can revert back to your GUI session (which is technically the console where your X server is running) by pressing “Ctrl + Alt + F7.” Alternatively, if you want, you can also restart the GUI from within the virtual console by running the following command:
When everything freezes
Unfortunately, there are times when everything (including your keyboard) becomes unresponsive. How should you tackle this scenario? The magic SysRq key comes to your rescue here. Unlike what its name suggests, the magic SysRq key is in fact a combination of keys that lets you talk to the kernel directly, irrespective of the state your system is currently in, allowing you to solve freezes/hangs where nothing seems to be responding.
Here are the key combinations we are talking about:
- Alt + SysReq + F: This key combination asks the kernel to kill one process (the most expensive one) at a time.
- Alt + SysReq + K: This key combination asks the kernel to kill all applications/processes in one go.
- Alt + SysReq + REISUB: This key combination asks the kernel to perform a clean reboot of the system.
Here’s how the third key combination (in the list above) performs a clean reboot:
- R: Switch to XLATE mode
- E: Send SIGTERM to all processes except init
- I: Send SIGKILL to all processes except init
- S: Sync all mounted file systems
- U: Remount all file systems as read-only
- B: Reboot
TIP: you can remember the combination REISUB as the reverse of BUSIER.
It’s clear that the “Alt + SysReq + REISUB” key combination is a better alternative than going for a cold reboot of your system.
Note: for the magic SysRq key to work, make sure that the “kernel.sysrq” parameter in the “/etc/sysctl.d/10-magic-sysrq.conf” file is set to 1.
There are many techniques that you can use to get out of app/OS freeze situations in Ubuntu. What’s worth stressing here – and important for you to understand – is that these techniques are there to save you from performing a physical reset or power on/off, which should ideally be the last resort in most cases.
Image credit: /home