OpenSUSE Linux Rants

OpenSUSE Linux Tips, tricks, how-tos, opinions, and news

My Resume  -  My LinkedIn Profile

September 11, 2007

Reboot a locked Linux box with the Magic SysRq Keys

by @ 3:25 pm. Filed under General Linux, How-To

I ran across this rather informative Wikipedia page about something called the “Magic SysRq key.” It is a mechanism built into the kernel that allows you to reboot a machine without having to hold in the Power button. Because your disks don’t have a chance to sync, and other complications that can occur with such a shutdown, this is a great alternative. If your system becomes completely unresponsive, this is a forceful way to reboot the machine, but more graceful than the 6-second power button charade.

First, to see if your machine is set up to do this, run this command:

cat /proc/sys/kernel/sysrq

If you see a “0”, it is disabled. If you see a “1”, it is enabled.

To enable it, do this:

echo 1 > /proc/sys/kernel/sysrq

To disable it, do this:

echo 0 > /proc/sys/kernel/sysrq

Once you have it enabled, you can proceed to perform the operation.

To do this, you will need to hold down the ALT and SYSRQ (or PRINT SCREEN) buttons while typing the following key sequence:

(taken from wikipedia)

Alt + SysRq + R – takes the keyboard out of raw mode.

Alt + SysRq + E – terminates all processes (except init).

Alt + SysRq + I – kills all processes (except init).

Alt + SysRq + S – synchronizes the disk.

Alt + SysRq + U – remounts all filesystems read-only.

Alt + SysRq + B – reboots the machine.

One thing to keep in mind, however, is that you will want to give the machine time to complete each command, especially time between the last three commands. You want to make sure that the machine syncs the disk before remounting the filesystems, and you want to wait a moment to reboot the machine after it performs the remount.

OpenSUSE Linux Rants
Official OpenSUSE Linux Site

internal links:


SUSE Resources

search blog:


September 2007
« Aug   Oct »

51 queries. 1.747 seconds