Appearance
The System Request key, "SysRq" in English keyboards ("Pet Sis" in Spanish ones, short for "Petición de Sistema") is the "seemingly useless" key sitting right next to your "Pause" key (also "seemingly useless").
However, this key plays an important role for a Linux System administrator, because it can be used to send system calls directly to the kernel. Sometimes, speaking directly to the kernel is the only way to save the day.
For example... imagine that suddenlty your whole system hangs. It's frozen... there's some process using 100% of the resources of the system.. your mouse doesn't move.. the Control+Alt+F2 key doesnt work... you can't do anything! Arghh!! what to do!!??
In Windows the only possible solution to this situation would be to forcefully disconnect your PC, make it loose any data you had sent and take the risk to damage your hard disk, motherboard, CPU and all the hardware that you were using at that time.
However, if you are using the Linux kernel, there's still some chance for salvation.... sending a System Request...
- Press
AltGr
+SysRq
+r
(unRaw, turns off raw mode in your keyboard so it works outside of GUI apps) - Press
AltGr
+SysRq
+e
(tErminate, sending a SIGTERM to close gracefully the running programs) - Press
AltGr
+SysRq
+i
(kIll, send a SIGKILL to inmediatelly close the remaining programs) - Press
AltGr
+SysRq
+s
(Sync, saving the data to the disk so that you won't loose the last changes) - Press
AltGr
+SysRq
+u
(Unmount all the disks, so that they won't be damaged) - Press
AltGr
+SysRq
+b
(reBoot the system)
WARNING
Many modern distributions of Linux have disabled this functionality in their kernel builds by default and you might need to explicitly enable it.
sh
# Activate the Magic SysRq commands for the current boot
echo 244 | sudo tee /proc/sys/kernel/sysrq
# Configure it for future boots
echo 'kernel.sysrq=244' | sudo tee /etc/sysctl.d/90-sysrq.conf
Note that the reason why I'm usng 244
instead of 1
is because I'm only activating the commands necessary for this chain. 4 (unRaw) + 64 (tErminate & kIll) + 16 (Sync) + 32 (Unmount) + 128 (reBoot) = 244
.
If you want to enable all commands, you can just use 1
instead of 244
.
Mnemonics ​
If you are like me, you'll forget this shortcuts easily. You can do like me, and write a post about it... or try to remember it by using some hints. Here are some of them:
- "Reboot Even If System Unbelievably Broken"
- "BUSIER" backwards
- "Raising Elephants Is So Utterly Boring"
You can also Sync the disks before terminating programs if you want:
- "Raising Skinny Elephants Is Utterly Boring" (because if they are fat it would rather be utterly deadly...)
Note: if you are not using a QWERTY keyboard the keys can be different for you You can also read more about other SysRq shorcuts here: https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html