Unexpected system hangs, crashes, or freezes in Ubuntu often disrupt critical work and can result in lost progress or data. These issues commonly appear as either a single unresponsive application, a partially frozen graphical interface, or a complete system lockup where keyboard and mouse input stop working entirely. Addressing these disruptions requires a combination of immediate recovery steps and longer-term preventive measures, depending on the underlying cause, such as hardware faults, insufficient memory, problematic drivers, or software conflicts.

Diagnosing the Type of Freeze

Identifying the scope of the freeze is the first step toward an effective fix. System hangs typically fall into three categories:

  • Application-level freezes, where only one program stops responding, but the rest of the system works.
  • Partial system freezes, where the graphical interface becomes unresponsive but keyboard shortcuts or a virtual terminal may still work.
  • Complete system freezes, where all input is ignored and only a forced reboot recovers the system.

Determining which type you're facing helps target the most effective solution.


Method 1: Recovering from Application-Level Freezes

Single application lockups occur when a program becomes unresponsive, but the rest of Ubuntu continues running. These can usually be resolved without rebooting.

Step 1: Open the System Monitor by pressing Ctrl + Alt + T to launch a terminal, then enter:

gnome-system-monitor

Locate the unresponsive application in the list, right-click it, and select "End Process" or "Kill". This immediately stops the problematic program.

Step 2: If the graphical interface is still responsive, use the xkill command. Press Alt + F2, type xkill, and press Enter. The cursor changes to an "X"; click the frozen window to force it to close.

These steps prevent the need for a full system restart when only one application fails.


Method 2: Regaining Control During Partial System Freezes

When the graphical interface locks up but the system is otherwise running, switching to a virtual terminal (TTY) allows you to terminate stuck processes and restore responsiveness.

Step 1: Press Ctrl + Alt + F3 (or try F4-F6) to access a TTY login prompt. Enter your username and password to log in.

Step 2: Use top or htop to view running processes and system resource usage. Identify any applications consuming excessive CPU or memory.

top

Step 3: Terminate the problematic process using its PID (Process ID):

kill <PID>

To return to the graphical desktop, press Ctrl + Alt + F2 or Ctrl + Alt + F1, depending on your Ubuntu version.


Method 3: Performing a Safe System Reboot with REISUB

When neither the desktop nor virtual terminals respond, the "magic SysRq" key sequence (REISUB) safely reboots Ubuntu and minimizes the risk of file system corruption.

Step 1: Hold Alt + SysRq (SysRq is usually the Print Screen key).

Step 2: While holding these keys, type the following letters in sequence, pausing a second between each:

R E I S U B

Each letter issues a command to the kernel, such as syncing disks and safely remounting filesystems, before rebooting. This method is safer than a hard shutdown and can prevent data loss.

Note: On some laptops, you may need to hold the Fn key as well. If the REISUB sequence does not work, verify that /proc/sys/kernel/sysrq contains 1. To enable it, run: echo 1 | sudo tee /proc/sys/kernel/sysrq

Method 4: Forced Power-Off (Last Resort)

If all recovery methods fail and the system remains completely unresponsive, a hard shutdown is the final option. Hold the physical power button for 5-10 seconds until the system powers off. Wait a few moments, then power it back on.

Caution: Forced shutdowns can cause data loss or file system issues, especially if files were being written at the time of the freeze. Use this method only when absolutely necessary.

Method 5: Analyzing and Preventing Future Freezes

Persistent hangs or crashes often indicate underlying issues that require further investigation and preventive action.

Check System Logs

Review logs to pinpoint the cause of repeated freezes. Use journalctl to examine kernel and system messages:

journalctl -b -1

This displays logs from the previous boot. To filter for errors:

journalctl -p err -b

Look for hardware errors, driver issues, or kernel panics near the time of the freeze.

Test Hardware and Memory

Hardware problems—especially faulty RAM or overheating—often cause system instability. Run memtest86+ from the GRUB boot menu to check for memory errors. Monitor CPU and GPU temperatures using lm-sensors and ensure fans are operating correctly.

Increase Swap Space and Adjust Swappiness

Systems with low RAM or heavy multitasking may freeze when memory runs out. Increase swap space to at least 8GB if you have 4GB RAM, and adjust the swappiness value to encourage earlier use of swap:

sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo 'vm.swappiness=100' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

This setup can prevent freezes caused by memory exhaustion.

Update Ubuntu and Graphics Drivers

Outdated system packages or graphics drivers frequently cause instability. Update your system:

sudo apt update && sudo apt upgrade -y

For graphics drivers, open "Software & Updates," navigate to the "Additional Drivers" tab, and select the recommended driver. For NVIDIA, switching from the "On-Demand" PRIME profile to "Performance" mode has resolved freezes for some users. Alternatively, try the open-source "nouveau" driver if proprietary drivers cause problems.

Review Recent Hardware or Software Changes

New hardware (such as Wi-Fi adapters with unreliable drivers) or recently installed third-party software can introduce instability. Disconnect or replace suspect hardware and uninstall or disable new software to test system stability.

Optimize BIOS Settings

For systems with AMD Ryzen CPUs, disabling power-saving features like C6 mode, Deep Sleep, or Global C-State Control in the BIOS has stopped random freezes for some users. Additionally, disabling CPU overclocking or Precision Boost Overclock may stabilize the system during high loads.


Applying these targeted recovery and preventive steps streamlines troubleshooting and significantly reduces the risk of future Ubuntu system hangs, crashes, or freezes. Regularly checking logs, keeping software updated, and monitoring hardware health will keep your system running reliably.