Linux instant safe (kernel level) reboot and more

Finally. Another post after weeks of ‘blog silence’ and constantly watching my ‘views’ count go up and down.

Anyway, this post is about how one can reboot a Linux machine instantly and safely when everything else has stopped responding (even the kernel). The reboot speed is only limited by how fast you type the keys of your keyboard, believe it or not.

Unlike the old-fashioned and not so safe ctrl+alt+del combo, this particular keyboard key combination reboots your machine safely, and more!

Now onto the main topic. First, we need to check if your system already allows this key combination. Issue

$> cat /proc/sys/kernel/sysrq

$>1

If the output (just like mine) is a ‘1’, then your system will respond to the combination. Otherwise, issue a command to input a ‘1’ in the aforementioned file whose contents we just viewed (sysrq) like opening it using vi or a text editor for example.

Moving on, the key combination is as follows:
hold down

ctrl + alt

then press your

sysrq

button and then the following letters/keys (shown with their corresponding meaning/effect):

r - force switch to keyboard mode (in case you can't even use your keyboard anymore)

e - send all processes the SIGTERM signal

i - sends all processes the SIGKILL signal

s - Sync filesystem (so you won't have to use 'fsck' next time you boot up)

u - Unmount all devices

b - Reboot immediately

Note that you can use each letter in ‘reisub’ with ctrl and alt to effect the desired task without the need to press the other combinations e.g. holding ctrl+alt then pressing sysrq buton then the b button to immediately reboot without unmounting your mounted disks, for example.

The point of the key combination show above is that when pressed in that manner, it ensures not only the fastest, but the safest way to reboot your machine. Cool huh?

The easy way to remember it, i.e. mnemonics, is it’s the inverse of ‘busier’. Nice!

One final tip: in case you don’t want to reboot and you just want to turn your machine off (either by going through the ‘safe’ key combination just mentioned or just turn it off instantly), you can hold down

 ctrl + alt

then press your

sysrq

button followed by

o

Comments and suggestions are always welcome!

Advertisements

Tags: , , ,

4 Responses to “Linux instant safe (kernel level) reboot and more”

  1. daily animals Says:

    Guess what? Your blog is amazing! I can’t remember when was the last time i’ve overcome such a good blog that almost all articles/posts were interesting and wouldn’t regret spending my time reading it. I hope you will keep up the great work you are doing here and i can enjoy my everyday read at your blog.

  2. f241vc15 Says:

    Thanks. I try to keep it balanced between programming, Linux, other techie stuff, and of course critical thinking and some bit of fun once in a while. But I think I sometimes overdo it with the techie part (^)__(^)
    Anyway, I’ll try to post more about my other interests some time soon. As well as my other opinions and ideas in my so called ‘mind’ (^)____(^)

  3. -DC- Says:

    Thanks for the tip! I was installing Linux on my PS3 and it hung during bootup. I was able to use these key combinations to get it rebooted without forcing a power-down that would have reset my internal PS3 settings!

  4. f241vc15 Says:

    No problem -DC-
    Glad my post could be of some help to people out there. And I’m always curious and fascinated by people using Linux, especially on relatively new and different ways.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: