5 Things to do when your Linux system GUI freezes

All operating systems freeze at some point and, Linux distributions are no exceptions. In this post, we are going to look at five methods you can apply to your frozen system before thinking of plugging out the power cable or holding down the power button to power off the PC.

Frozen GUI is mostly characterized by:

  • A single program stops responding and can’t close the window.
  • Nothing responds to mouse clicks or keyboard keys presses.
  • The mouse can’t move completely.

Major causes of a Frozen GUI

Some of the common causes that cause freezing/hanging in Linux are either software or hardware related issues. They include; system resources exhaustion, application compatibility issues, under-performing hardware, slow networks, device/application configurations, and long-running un-interruptable computations.

However, the main issue is mostly resource exhaustion, which often leads to a Deadlock. With that mind, let’s look at five things to do when your Linux system GUI freezes.

Things to do when your Linux desktop GUI freezes

1. Close Frozen Applications Using the X-Window

It is one of the easiest ways to kill freezing applications. There are several ways to open the X-Window. One is executing the command xkill in the terminal, as shown below.

xkill

Execute command xkill from Terminal
Execute command xkill from terminal

Your cursor will change from an arrow sign to an X sign, as shown in the image below. Click on the stubborn application window you wish to close anywhere but preferably on the exit button.

ubuntu-freeze-xkill cursor sign
ubuntu-freeze-xkill cursor sign

Alternatively, if you are unable to launch the terminal, you can use the following key combinations. Alt + F2 will open a dialog box where you will type the command xkill and hit Enter/Return key.

Using Alt + F2 command to open dialog box
Using Alt + F2 command to open the dialog box

This method is applicable in situations where your GUI has frozen, but you still have power over the mouse, and you can apply mouse clicks. Unfortunately, there are situations where even the mouse is frozen, and you cannot move the cursor. Here, you will need to apply the second method below.

2. Use the Linux Terminal

If it were a program running on the terminal, the easiest way would press Ctrl + C to stop it. This combination sends a SIGINT signal that interrupts/stops the program. In other systems, the ‘Delete‘ or ‘Break‘ can perform the same action.

Stop a program from Terminal using Ctrl + C
Stop a program from the terminal using Ctrl + C

Alternatively, if the process wasn’t running in the terminal, you can launch the terminal to stop it by their (Process Identification Number) PID’s. Press the combination Alt + F2 to open the dialog box. Type the command, gnome-terminal, and hit the Return/Enter key to start the terminal. 

From this point, we will use several utilities to see running processes in the system. One of the standard programs is TOP that comes preinstalled in most Linux systems. You can still use other services like HTOP if installed in your system. Launch the program and close the process that seems to consume much of the system memory.

Use TOP program to Close programs
Use the TOP program to Close programs

For example, in the image above, we will stop Firefox using the PID, which is 4240. Execute the command below.

sudo kill -9 4240

3. Use the Console (Virtual Terminal) to Kill Processes

If all of the above, including the terminal, doesn’t work, you will need to revert to Console mode. To enter Console mode, use press the combination Ctrl + Alt + F3. Your GUI interface will disappear and, you will drop into the Virtual Terminal, as shown below. You might be required to sign in with your username and password.

Press Ctrl + Alt + F3 to drop to Console mode
Press Ctrl + Alt + F3 to drop to Console mode

To come out of the console and return to the Graphical User Interface (GUI), press Ctrl + Alt + F2.

Just like in the Terminal, here, we can also use several commands and utilities to stop the running process. Since I have installed HTOP in my system, I will execute it and kill the processes using their PID’s.

Use HTOP to kill running programs in the console
Use HTOP to kill running programs in the console

Fortunately, with HTOP, unlike TOP, you don’t have to execute the KILL command. Select the process that you wish to stop and press the F9 (kill) key.

4. Use Putty to Login Remotely via SSH

Other than performing the above tasks on your native machine, you can access it remotely via putty and execute the same commands. Here, you will need to have an SSH server running and configured correctly on your target system. In this post, we will use putty to stop troubleshoot and stop the process on a remote Ubuntu server.

To install putty, execute the command below.

  •  Ubuntu/Debian
sudo apt-get install putty
  • CentOS, Red Hat and, Fedora
sudo dnf install putty
or
sudo yum install putty

Launch Putty
Launch Putty

Launch putty and enter the Ip-address of the target machine in the highlighted section, as shown in the image above. Click “Open”. You can get the Ip-address of any Linux system by running the command ifconfig.

Note, if the target PC is on a private network (i.e., is assigned a private address), you will need to be on the same network to get remote access on the system.

You will have to log in with your username and password, as shown in the image below.

Connect to Frozen system remotely using putty
Connect to Frozen system remotely using putty

Once you have an active session, you can now start troubleshooting for issues on the system. One of the common ways is using process utilities to check for all running processes in the system. In this example, we will launch TOP by executing the top command.

Launch TOP in Putty
Launch TOP in Putty

You can check some of the processes that are consuming the most memory and kill them using their PID’s. Some of the common kill commands include; pkill, kill, kill -9, killall. See the examples below.

pkill gedit
kill [Process_PID]
kill -9 [Process_PID]
killall -u [username]

You can check more options to use with the various commands using the –help option. For example, pkill –help will give you a list of all options you can use with the pkill utility.

5. Use Alt + SysRq + [Option-Keys] in the Console

The SysRq (System Request) is a specific combination of keys used to communicate directly with the Kernel regardless of the system state. It gives users the ability to send low-level commands to the Linux Kernel.

The SysRq key is commonly on the same key as Prnt-Scrn or the Home button. However, this might differ from one PC brand to another.

SysRq Ket on the keyboard
SysRq Ket on the keyboard

To use the SysRq, we will first need to go into console mode, as shown in the previous method. Press the combination Ctrl + Alt + F3. To revert to GUI, press Ctrl +Alt + F2. In case you cannot drop to console, follow the steps below.

Step 1) Press Alt+SysRq+R. It is a combination used to get the keyboard.
Step 2) If you were not able to drop to console previously, now run the Ctrl + Alt + F2 combination again.
Step 3) Press Alt+SysRq+ E. It terms all the processes running on the system.
Step 4) Press Alt+SysRq+ I. It Kills all running and stalled processes.
Step 5) Press Alt+SysRq+ S. It’s a combination to sync all your disks connected to the system preventing data loss.
Step 6) Wait for the OK message on the console. You can also check your HDD lights to see if the sync was successful.
Step 7) Press Alt+SysRq+ U. It re-mounts all disks connected to the system as read-only.
Step 8) Wait for the OK message. However, if it doesn’t appear, wait for 30 seconds and assume it finished then proceed.
Step 9) Press Alt + SysRq + B. Its a combination to forcefully reboot your PC.

All the letters used here follow the order R-E-I-S-U-B. They must be executed in the same order for this method to work on your system. Some of the common mnemonics used for these letters are ‘Reboot Even If System Utterly Broken’ or ‘Raising Elephants Is So Utterly Boring.’

There are more SysRq combinations that you can use on your frozen GUI other than the REISUB. You can find them in the Linux Kernel sources, SysRq Documentation.

Conclusion

Those are methods you can use to recover your system from a frozen state. They are here to save you from using the last resort that would be performing a physical reset or power on/off, which might lead to data loss. If you have another method that works for you, feel free to share it with our readers in the comment section.

Leave a comment

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