How To: Use the SysRq Key to Fix Any Linux Freeze

Use the SysRq Key to Fix Any Linux Freeze

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:

cat /proc/sys/kernel/sysrq

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!

Want to master Microsoft Excel and take your work-from-home job prospects to the next level? Jump-start your career with our Premium A-to-Z Microsoft Excel Training Bundle from the new Gadget Hacks Shop and get lifetime access to more than 40 hours of Basic to Advanced instruction on functions, formula, tools, and more.

Buy Now (97% off) >

Other worthwhile deals to check out:

Photos by IT News Africa, Lurenmall

Join the Next Reality AR Community

Get the latest in AR — delivered straight to your inbox.

Be the First to Comment

Share Your Thoughts

  • Hot
  • Latest