dufault.info

Ramblings of a phone weenie, Linux sysadmin, and other things geeky

19  07 2008

The Linux Magic SysRq key

I find it shocking how many people don’t know about this neat Linux key combination that let’s you execute various low level commands regardless of the system’s state (as long as it’s running and hasn’t panicked.)

From the Wikipedia page:

It is often used to recover from freezes, or to reboot a computer without corrupting the filesystem.

How it works: you press a key combination consisting of Alt, SysRq and your command key, and the Linux kernel will trigger that action, regardless of system load. This is a great way to recover a system quickly without triggering a hard reboot, as disk fscks can be lengthy, and involve data loss. Not to mention, the ability to sync the cached data from RAM to the disk is great, especially with computers running database services.

How to enable it? Easy, just add this to /etc/sysctl.conf on your Linux-based system, and run sysctl -p for the settings to become active:
kernel.sysrq = 1
# Copy paste command for the lazy...
$EDITOR /etc/sysctl.conf
sysctl -p

The best way to recover a system will involve multiple commands, this is taken from the Wikipedia excerpt:

unRaw (take control of keyboard back from X),
tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
kIll (send SIGKILL to all processes, forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
reBoot. These keystrokes should be entered a few seconds apart.

For more information about this nifty Linux-only feature, check out Wikipedia

Source: http://en.wikipedia.org/wiki/Magic_SysRq_key

Share and Enjoy:
  • Digg
  • del.icio.us
  • Mixx
  • StumbleUpon
  • Technorati

1 Comment

(Required)
(Required, will not be published)

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

« Scripts To Make Administrating Lots of MySQL Databases a Little Easier The Wordpress Google Analytics plugin screwed me »