Linux Desktop Frozen? 5 Proven Fixes Before a Hard Reboot
Linux desktop frozen? The whole machine has usually not crashed. Most often one program or the graphical session stopped responding while the kernel still runs, so a Linux frozen screen is often recoverable. That means you can often recover without a hard reboot, if you go through the steps in the right order. One popular last resort, the Magic SysRq "REISUB" sequence, is partly disabled by default on most distributions, and I show exactly which keys work where.
The SysRq defaults below were read on 2 December 2026 from the sysctl configuration files that Ubuntu 24.04, Debian 13, Fedora 44 and Arch Linux ship in their own packages. I decoded them with the bit table from the kernel's Magic SysRq documentation. The runaway-process example ran in a Debian 13 container with a 256 MB memory limit.
Contents
- Step 1: Linux desktop frozen, or the whole system?
- Step 2: with the Linux desktop frozen, switch to a text console
- Step 3: find the process that left Linux frozen
- Step 4: restart the graphical session on a Linux frozen desktop
- Step 5: Magic SysRq for a Linux frozen system, and why REISUB may not work
- After the reboot: find out why Linux was frozen
- FAQ: Linux desktop frozen
- What should I do first when my Linux desktop is frozen?
- Why doesn't REISUB work on my Linux?
- Is a hard reboot dangerous?
- How do I fix a Linux frozen screen without rebooting?
Step 1: Linux desktop frozen, or the whole system?
- The mouse moves but windows do not react: one application or the compositor is stuck. Wait 30 seconds, then try closing the program.
- Nothing reacts, but the disk light flickers and the fan spins up: often memory pressure. The system is swapping and may recover on its own.
- Caps Lock toggles its light: the kernel is still handling the keyboard, so the next steps can work.
Step 2: with the Linux desktop frozen, switch to a text console
Press Ctrl+Alt+F3 (or F2 to F6) to get a text login, independent of the graphical session. Log in there. To go back to the desktop, the graphical session is usually on Ctrl+Alt+F1 or F2, depending on the distribution. If you have a second computer, ssh into the frozen one instead. That works even when the screen is completely stuck.
Step 3: find the process that left Linux frozen
From the console, list the biggest memory and CPU users:
ps -eo pid,stat,%cpu,%mem,rss,cmd --sort=-rss | head
top -o %MEM
In my test, a Python script that kept allocating 10 MB blocks sat at the top of that list within 3 seconds:
PID STAT %CPU %MEM RSS CMD
2967 S 4.6 1.0 162184 python3 -c x=[] import time while True: ...
Stop it politely first, so it can save its state, and forcefully only if it does not exit:
kill -TERM 2967 # gone after SIGTERM in my test
kill -KILL 2967 # only if TERM did nothing
When a program uses up all the memory it is allowed, the kernel's out-of-memory killer ends it with SIGKILL. In the 256 MB container the second, faster script was Killed and its shell reported exit code 137 (128 + signal 9). If a program you did not kill shows exit code 137, look for an OOM message with journalctl -k | grep -i oom.
Step 4: restart the graphical session on a Linux frozen desktop
If the desktop itself is stuck, restart the display manager from the TTY. Use the one your system runs: sudo systemctl restart gdm (GNOME), sddm (KDE Plasma) or lightdm. This logs you out, so unsaved work in other programs is lost, but the machine keeps running. On GNOME on Wayland, the compositor and the session are one process, so restarting it always ends the session.
Step 5: Magic SysRq for a Linux frozen system, and why REISUB may not work
Magic SysRq keys go straight to the kernel. The kernel documentation says you press Alt+SysRq plus a command key (SysRq is the Print Screen key). The classic safe-reboot sequence "REISUB" means:
- R: turns off keyboard raw mode.
- E: sends SIGTERM to all processes except init.
- I: sends SIGKILL to all processes except init.
- S: syncs all mounted filesystems.
- U: remounts all filesystems read-only.
- B: reboots immediately.
Whether each key works depends on kernel.sysrq. 0 disables SysRq, 1 enables everything, and larger values are a bitmask: 2 console log level, 4 keyboard (R), 8 debug dumps, 16 sync (S), 32 remount read-only (U), 64 signal processes (E, I and the OOM key F), 128 reboot (B), 256 RT task nice. The distributions ship these defaults:
- Ubuntu 24.04:
/etc/sysctl.d/10-magic-sysrq.confsetskernel.sysrq = 176. Only S, U and B work; R, E and I are off. - Debian 13: systemd's
/usr/lib/sysctl.d/50-default.confsets0x01b6(438). R, S, U and B work; E, I and F do not. - Fedora 44 and Arch Linux: the same systemd file sets
16. Only S (sync) works.
So on a default Fedora or Arch machine with the Linux desktop frozen, pressing REISUB only syncs the disks, and nothing reboots. To allow the full sequence, the value you need is 4 + 16 + 32 + 64 + 128 = 244:
echo 'kernel.sysrq = 244' | sudo tee /etc/sysctl.d/90-sysrq.conf
sudo sysctl --system
cat /proc/sys/kernel/sysrq
Set this before the next freeze; you cannot change it on a frozen machine. Keep in mind that it lets anyone at the keyboard kill all processes or reboot. The bitmask only limits the keyboard: the kernel docs say root can always trigger any function through /proc/sysrq-trigger, for example echo f | sudo tee /proc/sysrq-trigger to call the OOM killer from an SSH session.
After the reboot: find out why Linux was frozen
journalctl -b -1 -p err # errors from the previous boot
journalctl -b -1 -k | grep -iE 'oom|gpu|nvidia|amdgpu|i915|hung'
Out-of-memory kills, GPU driver resets and "task hung" messages are the common causes. If memory is the cause, add swap or zram, or give heavy programs a limit. My Linux system monitoring guide shows how to watch memory and CPU over time, and my post on exit codes explains what 137 and other codes mean.
FAQ: Linux desktop frozen
What should I do first when my Linux desktop is frozen?
Wait half a minute, then press Ctrl+Alt+F3 for a text console, find the process using the most memory or CPU, and kill it.
Why doesn't REISUB work on my Linux?
Your distribution limits kernel.sysrq. Ubuntu allows only S, U and B; Fedora and Arch only sync. Set kernel.sysrq = 244 in /etc/sysctl.d/ to enable REISUB.
Is a hard reboot dangerous?
It can lose unsaved data and, rarely, damage files that were being written. That is why S (sync) and U (remount read-only) come before B in REISUB.
How do I fix a Linux frozen screen without rebooting?
Kill the runaway process from a TTY or over SSH, or restart the display manager. Both keep the system running.
Comments
Post a Comment