Header Banner
wonderhowto.mark.png
Gadget Hacks Next Reality Food Hacks Null Byte The Secret Yumiverse Invisiverse Macgyverisms Mind Hacks Mad Science Lock Picking Driverless

How to Use the SysRq Key to Fix Any Linux Freeze

Aug 5, 2012 05:21 PM
Aug 5, 2012 05:26 PM
Keyboard keys with "PrtSc" and "Num Lock" labels.

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.

Print Screen and SysRq keys on a keyboard.

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!

Photos by IT News Africa, Lurenmall

You already know how to use your phone. With Gadget Hacks' newsletter, we'll show you how to master it. Each week, we explore features, hidden tools, and advanced settings that give you more control over iOS and Android than most users even know exists.

Sign up for Gadget Hacks Weekly and start unlocking your phone's full potential.

Related Articles

Comments

No Comments Exist

Be the first, drop a comment!