Magic SysRq Keys Every Kernel Developer Should Know
The SysRq commands that matter for kernel debugging, each with what it does and when not to use it, plus how to enable them and the REISUB sequence.

When a machine stops responding to the keyboard and the network, there is often still a way to talk to the kernel: the magic SysRq key. It is a debugging back door built into the kernel, reachable from the keyboard, from a serial console or from a write to /proc/sysrq-trigger. Each letter is one command: dump all tasks, show blocked processes, sync the disks, crash on purpose to take a dump, reboot immediately. This post lists the keys a kernel developer uses, with what each does and, for every one, when not to press it, since several of them lose data or take the machine down. The reference is Linux Magic System Request Key Hacks.
Turning it on
SysRq must be compiled in (CONFIG_MAGIC_SYSRQ=y, true on distribution kernels) and enabled at run time. The control is the sysctl kernel.sysrq:
cat /proc/sys/kernel/sysrq176The value is a bitmask of which function groups are allowed. 0 disables it entirely and 1 enables everything. Other values enable a subset:
| Bit | Value | Allows |
|---|---|---|
| 2 | 2 | Control of the console log level |
| 3 | 4 | Keyboard control (SAK, unraw) |
| 4 | 8 | Debugging dumps of processes and so on |
| 5 | 16 | The sync command |
| 6 | 32 | Remount read-only |
| 7 | 64 | Signalling of processes (term, kill, oom-kill) |
| 8 | 128 | Reboot and power off |
| 9 | 256 | Nicing of all real-time tasks |
The value 176 above is 128 plus 32 plus 16: reboot, remount read-only and sync. On a development machine, enable everything:
sudo sysctl -w kernel.sysrq=1kernel.sysrq = 1To make it permanent, put kernel.sysrq = 1 in /etc/sysctl.d/. Leave it restricted on shared or production machines: anyone with a keyboard or console on a host with full SysRq can reboot it.
Three ways to send a key
On a keyboard, hold Alt and SysRq (often the Print Screen key) and press the command letter. On laptops, the Fn key may be needed. Over a serial console, send a break followed by the letter within five seconds (the exact method depends on your terminal program). From a shell, write the letter to the trigger file, which is the way you will use it most:
echo h | sudo tee /proc/sysrq-trigger
sudo dmesg | tail -n 2h
sysrq: HELP : loglevel(0-9) reboot(b) crash(c) show-all-locks(d) terminate-all-tasks(e) memory-full-oom-kill(f) kill-all-tasks(i) thaw-filesystems(j) sak(k) show-backtrace-all-active-cpus(l) show-memory-usage(m) nice-all-RT-tasks(n) poweroff(o) show-registers(p) show-all-timers(q) unraw(r) sync(s) show-task-states(t) unmount(u) force-fb(v) show-blocked-tasks(w) dump-ftrace-buffer(z)The reply goes to the kernel log. If you are on a console and see nothing, raise the log level with a digit key first, or read dmesg. Which commands your kernel offers depends on its configuration, and h prints exactly that list.
The keys, with when not to use each
| Key | What it does | When not to use it |
|---|---|---|
b | Reboot immediately, with no sync and no unmount | Whenever a clean shutdown is still possible; it can corrupt filesystems and lose buffered data |
c | Crash the kernel on purpose (a NULL dereference), triggering kdump if configured | On a machine without a crash kernel loaded or one holding data you need; it is a real crash |
e | Send SIGTERM to every process except init | On a production host where the services should shut down in order; use systemctl while it works |
f | Call the OOM killer to kill one memory hog | When the machine is not actually out of memory; it kills a process for nothing |
i | Send SIGKILL to every process except init | When you need the services to flush state; SIGKILL gives no chance to |
j | Thaw filesystems frozen by fsfreeze | When a backup process froze them on purpose and is still copying |
k | Secure Access Key: kill everything on the current virtual console | On a server you are using over SSH; it can kill your own session |
l | Print a backtrace of the active CPUs | Never harmful, but on a machine with 512 CPUs the output floods the log |
m | Print memory usage | Never harmful, only informational |
o | Power the machine off | When a clean shutdown still works; same data loss risk as b |
p | Print registers and flags of the current CPU | Not a blocker, just rarely informative on an idle CPU |
s | Sync all mounted filesystems | When the disk itself is failing, since the sync may hang forever |
t | Print the state and stack of all tasks | On a machine with tens of thousands of tasks, since the output can overflow the ring buffer |
u | Remount all filesystems read-only | When you still want to write logs or a crash dump to disk afterwards |
w | Print tasks in uninterruptible sleep (state D) with stacks | Not harmful, but the useful part is only on a hung system |
z | Dump the ftrace buffer to the console | When tracing is not enabled; there is nothing to dump |
0 to 9 | Set the console log level | When you want normal console output again afterwards, since it persists |
Entries to remember as the developer's set: l, w, t and m for diagnosing a hang without changing anything, s then u then b for a controlled emergency reboot, and c for forcing a crash dump from a hung machine.
Diagnosing a hang without rebooting
When the machine is slow or processes are stuck, the read-only keys show why. w lists tasks in uninterruptible sleep, the ones waiting on disk or a lock:
echo w | sudo tee /proc/sysrq-trigger
sudo dmesg | tail -n 12sysrq: Show Blocked State
task:jbd2/sda2-8 state:D stack:0 pid:312 tgid:312 ppid:2 flags:0x00004000
Call Trace:
<TASK>
__schedule+0x3c1/0x9a0
schedule+0x2f/0xa0
io_schedule+0x46/0x70
bit_wait_io+0x11/0x60
__wait_on_bit+0x4b/0x110
jbd2_journal_commit_transaction+0x1b3/0x1ae0
</TASK>The task named is stuck waiting for I/O inside the filesystem journal commit, which points at the disk. Lines like this explain a "frozen" system much faster than guessing. Use l when the problem looks like a CPU stuck in a loop, since it shows what each active CPU is executing:
echo l | sudo tee /proc/sysrq-triggersysrq: Show backtrace of all active CPUs
NMI backtrace for cpu 3
CPU: 3 UID: 0 PID: 2411 Comm: ticker-test Tainted: G O 6.12.0 #3
Call Trace:
<NMI>
...
ticker_spin+0x1d/0x40 [ticker]A CPU whose backtrace sits in your own function every time you press it is stuck there. This is the quickest way to find the culprit of a soft lockup before the watchdog even fires.
The REISUB sequence for a frozen desktop
A frozen graphical session with a working kernel is the classic use, and the mnemonic is REISUB, from the old advice "Reboot Even If System Utterly Broken". Wait a few seconds between keys so each step can finish:
r: take the keyboard out of raw mode, so the other keys work in a stuck X session.e: ask all processes to terminate with SIGTERM.i: kill the remaining ones with SIGKILL.s: sync the disks.u: remount read-only.b: reboot.
Modern desktops often handle this less often than they used to, but the principle remains: signal, sync, unmount, then reboot, in that order. Skipping s and u and pressing b first is how filesystems are damaged.
Using SysRq to capture a crash dump
When the machine is hung and you want a dump of memory to analyze later, c forces a crash on purpose, which hands control to kdump if a crash kernel is loaded. Check first, because without one the machine just panics:
cat /sys/kernel/kexec_crash_loaded1A 1 means a crash kernel is ready. Then:
echo c | sudo tee /proc/sysrq-triggerThe system panics, boots the crash kernel and saves the dump, usually under /var/crash. This is the correct tool for a hang that has no oops to read. Test it first on a healthy test machine so you know the dump path works before you need it.
Security and operational notes
A few cautions apply beyond the table.
SysRq over a serial console accepts the break sequence from anyone on the line. If the console is exposed, such as a remote management console, the break-triggered keys are reachable from there. Restrict kernel.sysrq accordingly.
The trigger file is root-only, but containers with access to /proc/sysrq-trigger can reboot the host. Container runtimes mask it for this reason; do not unmask it.
The keys act on the whole machine and are not logged with your identity, only that the command ran. Write down what you pressed when you share a log.


