Tuesday, April 22, 2008

The Linux Magic Sysrq - Help with a locked Linux Box

If you have ever had your Linux box lock up hard on you, you may find the following key sequence helpful, if you remembered to enable it in the kernal (CONFIG_MAGIC_SYSRQ). Don't enable this on a public box because anybody will have the power to just reboot the machine from the keyboard!

Be sure to hold down ALL the keys at once!!

  1. Alt+SysRq+s - sync the disk

  2. Alt+SysRq+e - try to nicely kill processes (be patient)

  3. Alt+SysRq+i - kill all processes, execpt for init

  4. Alt+SysRq+u - unmount disks (be patient again)

  5. Alt+SysRq+b - reboot

  • 'r' - Turns off keyboard raw mode and sets it to XLATE.

  • 'k' - Secure Access Key (SAK) Kills all programs on the current virtual
    console. NOTE: See important comments below in SAK section.

  • 'b' - Will immediately reboot the system without syncing or unmounting
    your disks.

  • 'o' - Will shut your system off (if configured and supported).

  • 's' - Will attempt to sync all mounted filesystems.

  • 'u' - Will attempt to remount all mounted filesystems read-only.

  • 'p' - Will dump the current registers and flags to your console.

  • 't' - Will dump a list of current tasks and their information to your

  • 'm' - Will dump current memory info to your console.

  • '0'-'9' - Sets the console log level, controlling which kernel messages
    will be printed to your console. ('0', for example would make
    it so that only emergency messages like PANICs or OOPSes would
    make it to your console.)

  • 'e' - Send a SIGTERM to all processes, except for init.

  • 'i' - Send a SIGKILL to all processes, except for init.

  • 'l' - Send a SIGKILL to all processes, INCLUDING init. (Your system
    will be non-functional after this.)

  • 'h' - Will display help (any other key than those listed
    above will display help)

No comments: