Magic SysRq Key Configuration and Usage Guide
The magic SysRq key can be used to recover from an unresponsive system instead of doing a hard shutdown. On keyboards where the SysRq key is not present, try PrtSc instead.
Enable
systemd blocks SysRq requests by default. To enable the SysRq keys, start by creating the following file:
sudo nano /etc/sysctl.d/99-sysrq.conf
With the following content:
kernel.sysrq = 244
This enables the r, e, i, s, u, b, k, f, j commands.
TipTo enable all commands, change
244to1. However, note that this may have security implications. For example, it can allow for dumping the contents of the CPU registers. For more information, refer to the SysRq key documentation.
Apply with:
sudo sysctl -p /etc/sysctl.d/99-sysrq.conf
Reboot
Follow the sequence below to perform a reboot:
| Shortcut | Description |
|---|---|
Alt+SysRq+R | Switch keyboard mode for the current virtual console from the raw mode to ASCII mode (also known as XLATE mode). (ref: https://unix.stackexchange.com/a/16555) |
Alt+SysRq+E | Send a SIGTERM to all processes, except for init, allowing them to terminate gracefully. |
Alt+SysRq+I | Send a SIGKILL to all processes, except for init, forcing them to terminate immediately. |
Alt+SysRq+S | Will attempt to sync all mounted filesystems. |
Alt+SysRq+U | Will attempt to remount all mounted filesystems read-only. |
Alt+SysRq+B | Will immediately reboot the system without syncing or unmounting your disks. |
It is also known as the “REISUB” sequence. A mnemonic idiom to remember it is “Reboot Even If System Utterly Broken”.
References
https://wiki.archlinux.org/title/Keyboard_shortcuts
https://docs.kernel.org/admin-guide/sysrq.html
https://www.linuxfromscratch.org/~ken/fontconfig-systemd/x/xorg-config.html