Linux is generally a pretty stable OS, but occasionally things happen. However, as long as your keyboard has a SysRq key, you'll never need to worry about freezes again.
The SysRq key functions allow you to perform various low level commands, even when your system is unresponsive. It can be used to recover from freeze-ups or to safely reboot without corrupting the filesystem.
To check that the SysRq key is enabled on your machine, simply enter this terminal command:
If it returns a "1", you're good to go. If it returns a 0, you can enable it yourself by running this command as root:
echo "1" > /proc/sys/kernel/sysrq
You now have a kernel option fittingly called the "Magic SysRq Key". Here are some of the more useful shortcuts you now have access to, although there are many more out there if you are curious.
- Alt+SysRq+r will return control of an unresponsive keyboard.
- Alt+SysRq+b to reboot without umounting or sync.
- Alt+SysRq+k to kill all programs on the current virtual console, including X.
- Alt+SysRQ+e sends SIGTERM to all processes except init, cleanly ending running processes.
- Alt+SysRQ+i sends SIGKILL to all processes except init, which can be used to end any processes that didn't close with "e".
- Alt+SysRQ+s syncs your system, flushing data from your cache to your disk.
To safely shut down after a particularly nasty kernel panic, HowToGeek recommends using the REISUB method. Press and hold down the magic SysRq combination (Alt + SysRq) and typing the following keys in order, slowly.
- r to return keyboard control to you.
- e to terminate all processes.
- i to kill any processes that weren't ended by SIGTERM.
- s to flush your data
- u to remount file systems
- b to reboot the computer.
Do you know any other good tricks using the SysRq key? If so, let us know in the comments!
Have an iPhone? Check out all 200+ new features coming in iOS 13.