Skip to content

Instantly share code, notes, and snippets.

@Fartomy
Created October 3, 2025 14:34
Show Gist options
  • Select an option

  • Save Fartomy/68696c39f4c398b7fc39d7997dfb83fc to your computer and use it in GitHub Desktop.

Select an option

Save Fartomy/68696c39f4c398b7fc39d7997dfb83fc to your computer and use it in GitHub Desktop.
Magic SysRq Key

πŸ’« Linux Magic SysRq Key

The Magic SysRq key (Linux Magic System Request Key) is actually an emergency key combination embedded within the Linux kernel.

Linux developers included this feature specifically for the following reasons:

  • When certain letters are pressed together with the Alt + SysRq (Print Screen) key combination, special commands are sent to the kernel.
  • These commands are processed directly by the kernel, even if the system is completely frozen (for example, the graphical interface is not working, and the keyboard does not seem to respond).
  • In other words, it is the operating system's backdoor control mechanism.
  • To recover the system β†’ Perform a safe shutdown/reboot on a crashed or unresponsive system.
  • To minimize data loss β†’ Synchronize disks (sync) and protect the file system.
  • To debug β†’ Obtain information from the system during kernel debugging.
  • To maintain control even in the worst-case scenario β†’ Even if the graphical interface fails or the shell freezes, the kernel still listens to these keys.

Usage

Performed by pressing Alt + SysRq (Print Screen key) + a key:

  • b β†’ Immediately restart the system (reboot)
  • o β†’ Shut down the system (power off)
  • s β†’ Synchronize disks (write data from RAM to disk)
  • u β†’ Switch file systems to read-only mode (to prevent corruption)
  • r β†’ Switch keyboard to β€œraw” mode (independent control from X or graphical interface)
  • e β†’ Send a β€œterminate” signal to all processes
  • i β†’ Send a β€œkill” signal to all processes
  • k β†’ Kill the current terminal (e.g., closes the graphical interface)

The most well-known rescue combination: Alt + SysRq + R E I S U B -> Hold down the Alt + SysRq keys while pressing each one in turn.

(R – check keyboard, E – terminate, I – kill, S – sync, U – unmount, B – reboot)

This allows you to β€œsafely restart a frozen computer.” Magic SysRq = The kernel's secret rescue menu. Even if normal methods don't work, when the system crashes or freezes, you can at least:

  • recover data,
  • shut down properly,
  • and obtain information for debugging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment