Q: How do I enable the kernel's Magic SysRq key sequences, to be able to do low-level debugging and control of the machine as described in /usr/src/linux/Documentation/sysrq.txt?

A: In many Linux installations, SysRq (System Request) is disabled by default. To re-enable it, edit /etc/sysctl.conf to insert "kernel.sysrq = 1". The "Magic SysRq" keystrokes will then become available (if support is compiled into the kernel — see below).

The SysRq key is the same as the Print Screen key.

If X locks, alt-SysRq-r regains control of your keyboard by taking the console out of Raw mode.

alt-SysRq-k kills everthing on the current virtual terminal

If your whole machine hangs, you can do

alt-SysRq-s (sync)

alt-SysRq-u (unmount)

alt-SysRq-b (boot)

Umounting and rebooting in this fashion after a hang should eliminate the necessity to perform an fsck during the subsequent reboot.

If you're getting kernel error messages scrolling by too quickly, you can do ctrl-SysRq-0 (error logging level 0).

Linux admins enable SysRq ordinarily only when doing cutting-edge, crash-prone work such as kernel development. However, you may find it useful if you are reasonably careful not to invoke it accidentally.

If you compile custom kernels (or suspect SysRq doesn't work in your Linux distribution's precompiled kernel because of omitted support for this option), you will want to include the CONFIG_MAGIC_SYSRQ=y kernel option.