Magically reboot your frozen Linux machine with the keyboard! 🧙
Sometimes, my Ubuntu machine tends to freeze up and I would be unable to restart or shut it down. I’ve always just held the power button until it is forcibly shut down, but I felt it has always been rather harmful. So, I’ve set about looking for a better way, and I found out about the magic REISUB key. Basically, it goes like this:
Hold the
AltandSysRqkeys, then slowly type outR E I S U B.
Found the original article over here, but it simply says how to do it, without explaining, so I dug deeper.
This stack exchange answer here provides a good answer:
-
R- switches keyboard (raw) mode to XLATE mode, short for translate mode. -
E- gracefully terminates all running programs by sendingSIGTERMsignals to all processes exceptinit.SIGTERMgives processes a chance to clean up and free up their resources, save data, etc. -
I- forcibly kills all running programs. BasicallyE, but for those processes that refuses to shut down. Best if you wait a bit before pressing this button forEto gracefully shut down processes. -
S- syncs all disks and flushes their caches, so that cached data can be written without losing data. -
U- unmounts all disks, then remounts them as read-only. Read-only as a safety measure. -
B- reboots the system. Like, a hard reset similar to holding the power button.
However…
On Ubuntu (which is the one I use, not sure about other distros), R, E, and I are disabled.
And…
If your intention is to simply shut down the PC without rebooting, replace B with O, which is the key for shutdown.
More details here (Wikipedia’s Magic SysRq key). 🧙🧙