Archive for January 17th, 2010

Raising Elephants Is So Utterly Boring

by on Jan.17, 2010, under Code, Posts

“Raising Elephants Is So Utterly Boring”

This is a simple mnemonic for remembering the sequence of keys to press when things go a mess under Linux.

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

I just recently used the SysRq key on my laptop, which had frozen after I applied some updates through the update manager. Under the condition that I had not known this key combination, I would have had to resort to a hard restart which is harmful to computer hardware and especially file systems.

When my system froze after it had completed its boot sequence, I held FN + ALT + SysRq and then pressed “R E I S U B”. After pressing this key sequence, my system safely restarted.

Here’s a simple shell script to enable the sysrq key for you. (It’s not perfect, but it will get the job done.) Keep in mind that you need to be root when doing this.

#!/bin/bash 

if [[ ! "$(cat /proc/sys/kernel/sysrq)" -eq "1" ]];
 then
      echo "Would you like to enable the SysRq key? (yes|no)";
      read answer;
         if [[  "$(echo ${answer} | egrep 'Y|y')" ]];
          then
              echo "Enabling sysrq..."
              echo "1" > /proc/sys/kernel/sysrq;
          else
               echo "Exiting!";
               exit 0;
         fi
 else
    echo "The sysrq is enabled!";
    exit 0;
fi

I want to thank a friend from Florida who had informed me of this wonderful and useful key.

Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!