Open In App

How To Handle Ubuntu Freezes

Last Updated : 28 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Despite being the most robust and lightweight operating system, Ubuntu is not immune from occasional freezing and hiccups. In this article, we will discuss about the reasons behind system freezes, and explore methods for diagnosing these issues. Additionally, we will also discuss the steps that should be taken if one finds themselves confronted with such a problem.

Problem Description

There are a variety of system freezes, a complete system lockup to a single unresponsive program. The root cause of the problem can range from hardware issues to software conflicts or an incompatible driver. Understanding the cause of the problem makes it easier for us to apply the necessary solution and implement the preventive measures. Let us take a look at some of the common symptoms of a system freeze.

  1. Frozen windows and applications.
  2. Not able to switch between windows or workspaces.
  3. Unresponsive mouse and keyboard inputs.
  4. Keyboard shortcuts don’t work.
  5. Unmoving Cursor.

Problem Solution

Here is a set of solutions for various types of freezing issues that one might encounter in a Ubuntu operating system. Now that we’ve identified the symptoms, let’s explore potential solutions to tackle Ubuntu freezes effectively.

Note: The solution may vary based on the specific cause of the freeze. It’s advisable to try these steps one at a time and observe the system’s behavior after each modification.

Update Your System

Ensure your system is up to date with the latest software patches and updates. Use the following commands in the terminal:

sudo apt update
sudo apt upgrade

Review Graphics Drivers

Outdated or incompatible graphics drivers can contribute to system freezes. Update your graphics drivers using the appropriate commands or graphical tools for your hardware.

ubuntu-drivers devices
sudo ubuntu-drivers autoinstall

Investigate Software Conflicts and Manage Resources

Incompatible or conflicting software can lead to freezes. Review recently installed applications, extensions, or updates. Uninstall or disable any suspicious software and observe if the freezes persist. Also identify resource-intensive processes and consider closing unnecessary applications.

Tweak Kernel Parameters

Adjusting kernel parameters can sometimes alleviate freeze issues. Edit the GRUB configuration file with the following and modify the line starting with GRUB_CMDLINE_LINUX and update it with parameters like nomodeset or acpi=off. Save the file and update GRUB.

sudo nano /etc/default/grub
sudo update-grub

g7

Single Program Unresponsiveness Solutions

Using the xkill command

Sometimes, a misbehaving application can cause ubuntu system freezes. The xkill command provides a swift and efficient way to terminate unresponsive windows without resorting to a system reboot. Press Alt+F2 and execute the command “xkill”. In the dialog box that appears, type the command “xkill” and press Enter. Your cursor will transform into an X shape. Hover over the troublesome window and left-click to terminate it. Right-clicking will abort the action and restore your cursor to its normal state. The steps to employ the xkill command is given below.

  1. Access the run dialog using ALT+F2
  2. Invoke the xkill command by executing it in the dialog box
  3. Cursor will undergo a visual transformation
  4. Target the unresponsive window and left-click to terminate the program
  5. Abort action if necessary by pressing the right mouse button.

1

2

Using the terminal to kill the program

The terminal commands offers an efficient and powerful way to handle unresponsive programs. Some of the following steps can be employed to terminate the troublesome programs. Launch the terminal and run the following command to kill a running program which is unresponsive. If you know the name of the unresponsive program, you can use the killall command to terminate it.

killall <program-name>

3

If you are uncertain about the exact program causing issues, you can use the following command to list all running processes along with their Process IDs (PID). You can also kill the program using its PID (Process ID). To find all the running programs and their PID’s run the following command. Alternatively you can also launch your System Monitor to view all the running processes along with their PID’s.

ps

4

6

You can also use the PID to kill a process. In situations where a regular termination doesn’t work, you can forcefully end a process using the -9 signal (SIGKILL). This ensures that the process is immediately terminated. Take a look at the following commands.

kill <PID>
kill -9 <PID>

7

8

If your graphical user interface (GUI) is frozen, preventing you from accessing the navbar or other UI entities, you can initiate a forced hot boot by executing the following command. This command sends a signal 9 (SIGKILL) to terminate all running processes, effectively restarting the system.

kill -9 -l

If the mouse interface is not working. You can use any one of the following shortcuts to access the terminal. Try one of the following shortcuts to access the terminal window.

  • Press ALT + F2
  • Press CTRL + ALT + T
  • Press ALT + CTRL + F1

g1

Restarting the display manager can often resolve issues related to the graphical interface. To restart the display manager run the following command. It is important to note that display managers may vary depending on the distrubutions version and flavour. Verify your display manager and replace the command with the appropriate display manager name.

sudo service gdm3 restart

g2

Using the Magic System Request Key

The Magic System Request Key combination (ALT + SysRq) is a potent tool and can be employed to access the kernel’s terminal, allowing the execution of low-level commands irrespective of the system’s current state. The following keys can be pressed while holding ALT and SysRq to send certain signals to the kernel. Refer the following for the key bindings and their respective behavior.

  • B – Reboot: Initiates a system reboot.
  • E – Send Terminate signal to all processes except for init: Sends a terminate signal to all processes, excluding the init process.
  • S – Synchronize all mounted file-systems: Initiates a synchronization of all mounted file-systems, ensuring data consistency.
  • I – Send Kill signal to all processes except for init: Sends a kill signal to all processes, excluding the init process.
  • U – Remount file-systems as read-only: Remounts file-systems as read-only, safeguarding against potential data corruption.
  • R – Activate XLATE mode

By default the R, E, I signals doesn’t work, we must modify the magic-sysrq configuration file to enable it. Execute the following command.

sudo nano /etc/sysctl.d/10-magic-sysrq.conf

g3

Make the necessary modifications to enable the R, E, I signals. Modify the “kernel.sysrq = 176” to “kernel.sysrq = 244”. Please note that the use of the nano text editor is demonstrated here, but users can choose their preferred text editor. Here certain signals are associated with certain numerical values. These signals provide functionalities that were discussed at the beginning of this section such as Rebooting, Terminating and more. However the distributions gets shipped with restrictions which disable these signals by default for security reasons. The change from 176 to 244 allows for the inclusion of additional signals (R, E, I) that may not have been activated initially which expands the range of the functionalities that we can use through the magic sysrq tool.

kernel.sysrq = 244 

g4

Holding the Alt + SysRq keys type RESUIB. By typing these keys the following actions are performed.

  • R – Switch the keyboard to Raw mode:
  • E – Send SIGTERM to all processes except init (PID 1)
  • S – Sync all mounted filesystems
  • U – Remount all mounted filesystems in read-only mode: Ensures that no further writes to the filesystems occur.
  • I – Send SIGKILL to all processes except init.
  • B -Immediately reboot the system: Initiates a quick reboot of the system.

g6

Advantages of using the Magic System Request Key

  • Emergency Kernel Access
  • Diverse Signal Options
  • Data Integrity Safeguards

Conclusion

In conclusion, while Ubuntu stands out as a robust and lightweight operating system, it is not impervious to occasional freezes and hiccups. This article has shed light on the various causes behind system freezes, ranging from hardware issues to software conflicts, and has offered a comprehensive guide on diagnosing and resolving these issues effectively. By updating the system, reviewing graphics drivers, managing resources, and utilizing advanced techniques such as the xkill command and the Magic System Request Key, users can navigate and mitigate freezing problems with greater confidence and efficiency, ensuring smoother and more reliable Ubuntu experiences in the future



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads