This article is written like a manual or guidebook. (June 2012) (Learn how and when to remove this template message)
The magic SysRq key is a key combination understood by the Linux kernel, which allows the user to perform various low-level commands regardless of the system's state. It is often used to recover from freezes, or to reboot a computer without corrupting the filesystem. Its effect is similar to the computer's hardware reset button (or power switch) but with many more options and much more control.
This key combination provides access to powerful features for software development and disaster recovery. In this sense, it can be considered a form of escape sequence. Principal among the offered commands are means to forcibly unmount file systems, kill processes, recover keyboard state, and write unwritten data to disk. With respect to these tasks, this feature serves as a tool of last resort.
The key combination consists of + and another key, which controls the command issued. may be released before pressing the command key, as long as remains held down.
The combinations always assume the QWERTY keyboard layout; for example, on a Dvorak Simplified Keyboard, the combination to shut the system down uses the key instead of . Furthermore, some keyboards may not provide a separate key. In this case, a separate key should be present.
On some devices, notably laptops, the key may need to be pressed to use the magic key.
From user space programs (such as a command line shell), SysRq may be accessed by writing to /proc/sysrq-trigger (e.g.,
echo s > /proc/sysrq-trigger).
|Set the console log level, which controls the types of kernel messages that are output to the console||-||-|| -
|Immediately reboot the system, without unmounting or syncing filesystems|
|Perform a system crash. A crashdump will be taken if it is configured.|
|Display all currently held Locks (CONFIG_LOCKDEP kernel option is required)|
|Send the SIGTERM signal to all processes except init (PID 1)|
|Call oom_kill, which kills a process to alleviate an OOM condition|
|When using Kernel Mode Setting, switch to the kernel's framebuffer console.
If the in-kernel debugger kdb is present, enter the debugger.
|Output a terse help document to the console
Any key which is not bound to a command should also perform this action
|Send the SIGKILL signal to all processes except init|
|Forcibly "Just thaw it" - filesystems frozen by the FIFREEZE ioctl.|
|Kill all processes on the current virtual console (can kill X and SVGALib programs, see below)
This was originally designed to imitate a secure attention key
|Shows a stack backtrace for all active CPUs.|
|Output current memory information to the console|
|Reset the nice level of all high-priority and real-time tasks|
|Shut off the system|
|Output the current registers and flags to the console|
|Display all active high-resolution timers and clock sources.|
|Switch the keyboard from raw mode, used by programs such as X11 and SVGALib, to XLATE mode|
|Sync all mounted filesystems|
|Output a list of current tasks and their information to the console|
|Remount all mounted filesystems in read-only mode|
|Forcefully restores framebuffer console.
For ARM processors, cause ETM buffer dump instead.
|Display list of blocked (D state) tasks|
|Used by xmon interface on PowerPC platforms.|
|Show global CPU registers (SPARC-64 specific)|
|Dump the ftrace buffer|
|Print a summary of available magic SysRq keys|
A common use of the magic SysRq key is to perform a safe reboot of a Linux computer which has otherwise locked up (abbr. REISUB). This can prevent a fsck being required on reboot and gives some programs a chance to save emergency backups of unsaved work. The QWERTY (or AZERTY) mnemonics: "Raising Elephants Is So Utterly Boring", "Reboot Even If System Utterly Broken" or simply the word "BUSIER" read backwards, are often used to remember the following SysRq-keys sequence:
When magic keys are used to kill a frozen graphical program, the program has no chance to restore text mode. This can make everything unreadable. The commands textmode (part of SVGAlib) and the reset command can restore text mode and make the console readable again.
On distributions that do not include a textmode command, the key command ++ may sometimes be able to force a return to a text console. (Use , , , ..., , where n is the highest number of text consoles set up by the distribution. ++ would normally be used to reenter GUI mode on a system on which the X server has not crashed.) There are also distributions where ++ opens text consoles, ++ reenter GUI mode, ++ reenter GUI mode on the login page, in order to log another user.
On newer kernels (since 2.6.12), it is possible to have more fine-grained control over how the magic SysRq key can be used. On these machines, the number written to /proc/sys/kernel/sysrq can be 0, 1, or a number greater than 1 which is a bitmask indicating which features to allow. On Ubuntu this is set at boot time to the value defined in /etc/sysctl.d/10-magic-sysrq.conf .
While the magic SysRq key was originally implemented as part of the kernel's keyboard handler for debugging, the functionality has been also exposed via the proc filesystem and is commonly used to provide extended management capabilities to headless and remote systems.
The Linux daemons sysrqd and tcpconsole provide a method of accessing SysRq features over a TCP connection after authenticating with a plain-text password. The hangwatch daemon will invoke pre-configured SysRq triggers when system load average exceeds a certain threshold.
The Xen hypervisor has functionality to send magic commands to hosted domains via its xm sysrq command. Additionally, a SysRq command can be invoked from a Xen paravirtual console by sending a break sequence + followed by the desired key.
Many embedded systems have no attached keyboard, but instead use a serial console for text input/output to the running system. It is possible to invoke a Magic SysRq feature over a serial console by sending a serial break, followed by the desired key. The method of sending a break is dependent on the terminal program or hardware used to connect to the serial console.
IBM mainframe partitions can invoke the Magic SysRq feature using + followed by the desired key on 3270 or HMC console.