What should I do when Ubuntu freezes?

Ubuntu is the most frequently used Linux distribution for most users. While using Ubuntu, users can face freeze conditions such as a program stuck, the mouse not working, or Ubuntu freezing at boot time. These problems do not allow the user to perform normal operations, halting the system’s overall performance.

This article will demonstrate ways to unfreeze Ubuntu:

Reason 1: Ubuntu Freezes at Boot Time

Sometimes, Ubuntu stucks at boot and the user is not able to access the login screen. It frequently occurs even if the user repeatedly restarts the machine. 

Solution: Configure the GRUB

The solution that can be considered is to boot the system from the GRUB and load the Kernel without a video driver. This will have no impact on Ubuntu, but the graphics may be. Go through the below-mentioned steps:

Step 1: Forcefully Shutdown the System

The first step is to forcefully shut down the operating system and turn it on again.

Step 2: Enter Into the GRUB

At the boot time, enter the GRUB menu by pressing and holding the right “Shift” key. Press the “E” from the keyboard:

Step 3: Modify Linux Kernel Parameter

Locate the line starting with “linux”, and at the end of the line after “quiet splash”, add the given line and press “F10” or “Ctrl+X”’:

nomodeset

Note: If the above line does not work, the user can try the “nouveau.noaccel=1”.

Verify the Result

The Ubuntu system has been booted as shown below:

Step 4(Optional): Change the GRUB File Settings (Permanent Solution)

The above-implemented steps are the temporary solution; the user can apply this in the GRUB file to make it permanent.

Change the line “GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” to “GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash nomodeset” by opening the GRUB file using the following command:

$ sudo gedit /etc/default/grub

After saving the file update the GRUB using the following command:

$ sudo update-grub

Warning: Do not change the other content of the file, as this is quite harmful to the operating system.

Reason 2: If the Specific Program Stops Working

This case is the most common and faced by most users; a specific program stops working, and it does not allow us to use any other program further. 

Solution: Kill the Process 

The user can simply close the application; there is a chance it will give you the option to force quit or wait for the application. 

If the application is not closing, press the “Alt+F2”, type the “xkill” and hit the enter button. The mouse cursor will change into the “X” simply click on the application and close it. The application will be closed without any confirmation, as shown:

If you have terminal access, open it by pressing the shortcut “Ctrl +Alt+T” and run the “pgrep” with the program name to get its process ID. Use the “kill” command and kill the process:

$ pgrep <program nme>                            #To get the Process ID
$ kill -9 <Process ID>                           #Kill the Process Using ID

For example, if the “Krita” software is creating the issue, kill it in the following way:

$ pgrep krita
$ kill -9 11802

The application is closed.

The user can also consider the “pkill” command that is a combination of the “pgrep” and “kill”. It will close the software/application in a single command:

$ pkill <process name>

Reason 3: if the Mouse is Not Working

The users might face a problem where their mouse is not working, and they cannot operate the system furtherly. 

Solution: Restart the Display Manager

The user can restart the display manager; the process can be done by the keyboard. This will close all the running applications that are in use. 

To do so, open the terminal by pressing “Ctrl+Alt+T” or use the “Alt+F2” and type the  “gnome-terminal”. Now, restart the display manager through the following command based on your desktop environment:

$ sudo systemctl restart gdm                     #For Gnome Desktop Environment
$ kquitapp5 plasmashell && kstart5 plasmashell   #For KDE Desktop Environment
$ xfce4-panel -r && xfwm4 --replace              #For Xfce Desktop Environment

This will take the user to the login screen. Desktop service will restart

Alternatively, press the “Ctrl+Alt+F2” to return to the login screen.

Conclusion

There are multiple kinds of freezing states of Ubuntu, such as freezing at boot time, the specific program stopping working, or the mouse not working. To fix the booting time freezing, users must configure the GRUB. If the problem is because of any program, then forcefully kill the process as stated. Moreover, restarting the display manager also fixes this issue if it is due to the mouse not working. 

This write-up has illustrated the various reasons why Ubuntu freezes and the solution to all these reasons.