Seeking advice: Is there a keyboard shortcut to gently reboot from a freeze?

Infant Linux user here, have had it installed dual-boot for less than a month; sometimes the monitor freezes and it seems like the only solution is to reboot. I don’t want to keep having to use the power button on the tower because I know that’s awful for the computer. Knowing the inherent plasticity of Linux, I wonder if there’s a way to gently reboot via keyboard? Or if there’s a work-around, like a shortcut to call up bash and a command I can enter from there? I’ve seen a similar question here on the forum regarding the institution of a reboot keyboard shortcut but it seemed like most of the replies revolved around entering a command, which I can’t do if the computer is frozen. I should probably investigate the freeze issue and get to the root of the problem but until then it would be great to be a little kinder to my PC!

https://wiki.archlinux.org/title/Keyboard_shortcuts#Kernel_(SysRq)

(though … I really should encourage them to use 244 instead…)

2 Likes

There are a few things you could try, and that you should try first, in this order… :arrow_down:

  1. Check whether the kernel is still alive by trying to toggle the NumLock key on your keyboard. If the indicator LED does not switch off or on as you press the key, then the kernel’s dead, and then only the reset button on the computer housing will bring solace.

  2. If the kernel is still alive — see above — you can try switching to a character-mode login console, also known as a tty. You do this by pressing Ctrl+Alt+F3. Do however keep in mind that this might take some time, depending on how hard your CPU is being hit by whatever process has locked up. If your kernel is still alive, then it will eventually switch over, but it’ll take time because the kernel is experiencing a local denial-of-service. Once you are at the tty — again, let it take its time — log in and issue the command…

sudo systemctl reboot
  1. If enabled on your system, you can try the so-called Magic SysRq keys. This is a combination of key inputs that go straight to the kernel and should work fairly quickly, although you still need to take about 5 seconds into account between each of the key presses. How this works is as follows… Press and hold the Alt and PrtSc/SysRq keys together, and then while holding them down, press the following keys in the order as given here:
    ° R
    ° S
    ° E
    ° I
    ° S
    ° U
    ° B

An easy mnemonic for remembering is to use the first character of every word in the sentence “Raising Skinny Elephants Is Still Utterly Boring”.

Each of the System Requests here-above is a direct command into the kernel itself, which will do the following…

  • R = unRaw the keyboard, i.e. taking the keyboard input away from the frozen process and assigning it to the console directly
  • S = emergency Sync, i.e. flushing all buffers to disk
  • E = send a tErminate signal to all running processes, i.e. ask them to exit gracefully, except for init, which in Manjaro is the systemd system manager
  • I = kIll all remaining processes, whether they like it or not
  • S = another emergency Sync
  • U = remoUnt all filesystems in read-only mode
  • B = reBoot by resetting the processor — this is equivalent to hitting the reset button
3 Likes