Magic SysRq key
This article contains instructions or advice. (June 2012) |

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 file system.[1]
This key combination provides access to features for 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.
The magic SysRq key cannot work under certain conditions, such as a kernel panic[2] or a hardware failure preventing the kernel from running properly.
Implementation
[edit]The Linux kernel contains sysrq.c,[3] which implements magic SysRq functionality. Magic SysRq functionality is called by serial devices[4][5] at a low level in the driver code.
Commands
[edit]The key combination consists of Alt+SysRq and another key, which controls the command issued. SysRq may be released before pressing the command key, as long as Alt remains held down.
The combinations always assume the QWERTY keyboard layout[6]. For example, on the Dvorak keyboard layout, the combination to shut down the system uses the R key instead of O. Furthermore, some keyboards may not provide a separate SysRq key. In this case, a separate PrtScn key should be present[7].
On some devices, notably laptops, the Fn key may need to be pressed to use the magic SysRq key, e.g. on Thinkpad Carbon X1 the SysRq is activated by pressing Alt+Fn+S simultaneously, then releasing Fn and S while still holding Alt.[8]
A complete list of commands is available in the official Linux Kernel Documentation on Linux Magic System Request Key Hacks.
Configuration
[edit]The feature is controlled both by a compile-time option in the kernel configuration, CONFIG_MAGIC_SYSRQ,[4] and a sysctl kernel parameter, kernel.sysrq.
On newer kernels (since 2.6.12[9]), it is possible to have more fine-grained control over how the magic SysRq key can be used.[10] 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 .
Uses
[edit]Before the advent of journaled filesystems a common use of the magic SysRq key was to perform a safe reboot of a locked-up Linux computer (using the sequence of key presses indicated by the mnemonic REISUB), which lessened the risk of filesystem corruption. With modern filesystems, syncing and unmounting is still useful to force unflushed data to disk, but is no longer necessary to prevent filesystem corruption (and may increase the risk of corruption in case the lock-up is caused by the kernel being in a bad state).[11] The default value of kernel.sysrq in distributions such as Ubuntu and Debian remains 176[citation needed] (allowing the sync, unmount, and reboot functions) and 438[12] (allowing the same functions plus loglevel, unraw, and nice-all-RT-tasks) respectively.
Another past use was to kill a frozen graphical program, as the X Window System used to have complete control over the graphical mode and input devices.
Other ways to invoke Magic SysRq
[edit]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. 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).[1]
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 signal, 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. A sysctl option needs to be set to enable this function.[13]
The Linux daemons sysrqd[14] and tcpconsole[15] provide a method of accessing SysRq features over a TCP connection after authenticating with a plain-text password. The hangwatch[16] 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.[17] Additionally, a SysRq command can be invoked from a Xen paravirtual console by sending a break sequence Ctrl+O followed by the desired key.
The Kernel-based Virtual Machine (KVM) hypervisor has functionality to send magic commands to hosted domains via its virsh send-key command. [18]
eg:
virsh send-key --domain domainname --keycode KEY_LEFTALT KEY_SYSRQ KEY_S
Chromebooks have a keyboard but no dedicated SysRq key. They use Alt+VolumeUp (Alt+F10) instead,[19][20][21] however some keys have a different function.[22][23]
Some Dell Laptops require the following sequence[24]:
- Sequentially press & hold Alt+Fn+R
- Release Fn+R
- While still holding Alt, press the desired key e.g., H
IBM Power Systems servers can invoke the Magic SysRq feature using Ctrl+O followed by the desired key from the Hardware Management Console.
IBM mainframe partitions can invoke the Magic SysRq feature using ^+- followed by the desired key on 3270 or HMC.
See also
[edit]- Stop-A, key sequence used to access Sun Microsystems's Open Firmware (OpenBoot)
- Console server
- KVM switch
- System console
References
[edit]- ^ a b "Linux Magic System Request Key Hacks". kernel.org. 2013-08-12. Retrieved 2017-05-21.
- ^ Khamlichi, Mel (18 Oct 2010), Use Magic SysRq Combination Key to Recover from a Frozen System in Linux, Unixmen, archived from the original on 20 August 2014, retrieved 21 Sep 2014.
- ^ "linux/drivers/tty/sysrq.c at master · torvalds/linux". GitHub. Retrieved 2025-03-27.
- ^ a b "linux/drivers/usb/serial/generic.c at 6537cfb395f352782918d8ee7b7f10ba2cc3cbf2 · torvalds/linux". GitHub. Retrieved 2025-03-27.
- ^ "linux/include/linux/serial_core.h at 6537cfb395f352782918d8ee7b7f10ba2cc3cbf2 · torvalds/linux". GitHub. Retrieved 2025-03-27.
- ^ "Magic SysRq key". LinuxReviews. Retrieved 2026-04-11.
- ^ "Linux Magic System Request Key Hacks — The Linux Kernel documentation". www.kernel.org. Retrieved 2026-04-11.
- ^ "Alt+SysRq on a laptop". Super User. Retrieved 25 July 2023.
- ^ Calleja, Diego (2012-07-17). "Linux 2.6.12". Linux Kernel Newbies. Retrieved 2013-08-31.
- ^ "QA/Sysrq". Fedora Project. 2013-05-09. Retrieved 2015-04-09.
- ^ "Documentation: sysrq: don't recommend 'S' 'U' before 'B'". Git (commit). Kernel. 2019-09-06.
- ^ "4.9. Restricting the use of the Magic SysRq key". Securing Debian Manual. Retrieved August 20, 2024.
- ^ Turner, Glen; Komarinski, Mark F (2003-03-31). "Magic SysRq key". Remote Serial Console How-To. The Linux Documentation Project. Retrieved 2015-05-08.
- ^ Danjou, Julien. "sysrqd". GitHub (project). Retrieved 2016-09-13.
- ^ van Heusden, Folkert. "tcpconsole". Archived from the original on 2017-08-31. Retrieved 2013-08-31.
- ^ Morgan, Paul. "hangwatch". GitHub. Retrieved 2013-08-31.
- ^ "27. The xm command quick reference", Enterprise Linux 5 Virtualization Guide, RedHat, retrieved 2013-08-31
- ^ "20.26. Sending a Keystroke Combination to a Specified Guest Virtual machine | Virtualization Deployment and Administration Guide | Red Hat Enterprise Linux | 7 | Red Hat Documentation". docs.redhat.com. Retrieved 2025-07-29.
- ^ "Debug Button Shortcuts". Chromium OS docs. Retrieved 2018-10-22.
- ^ "Change 29110: CHROMIUM: sysrq: treat F10 as magic sysrq key". Retrieved 2016-07-11.
- ^ "Chromium OS dev: SysRq in ChromiumOS' kernel". Retrieved 2016-07-11.
- ^ "Helping debug system hangs". The Chromium Projects. Retrieved 2018-09-25.
- ^ "CHROMIUM: sysrq: add ability for sysrq-x to signal chrome/X". Retrieved 2018-04-12.
- ^ "how to generate SysRq key combos on Dell XPS 7390 | DELL Technologies". Retrieved 2026-03-16.
External links
[edit]- "Documentation/sysrq.txt". Linux (kernel source tree). kernel.org. Retrieved 2017-01-31.
- "Linux Magic System Request Key Hacks". Linux (linux kernel documentation). kernel.org. Retrieved 2020-06-01.
- Morton, Andrew (2013-03-13). "Kernel patch to the -mm tree that added the /proc/sysrq-trigger feature: This makes sysrq facilities available to remote users". Retrieved 2015-04-09.
- Lawrence, Tony (2005-04-13). "Magic Sysrq Key on Linux". AP Lawrence. Retrieved 2015-04-09.
- Gall, Tom (2000-04-01). "Magic sys request". Developer works. IBM. Archived from the original on 2007-05-27. Retrieved 2013-09-03.