Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Sometimes I would like to shut down in a hurry. By hurry I mean 5 to 10 seconds. Assume I can run any script with root privileges in tty which I've prepared beforehand, and after 5 or 10 seconds the power will go out. What's the best way to minimize the damage (like maybe unmounting all devices, or closing all open files)?

share|improve this question
add comment

2 Answers

Anyway you can shutdown from terminal using the command,

sudo shutdown -h now


sudo poweroff

Afterwards you need to put your sudo password. Here is an answer describes how you can shutdown from terminal without entering password. To do so,

Just run sudo visudo from terminal and add the following line:

%user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/shutdown

This allows you to run the above commands, using sudo, however with no password. So, sudo poweroff or sudo shutdown -h now will now result in a password less shutdown.

If you want a step further ahead you can make a alias named stopnow or whatever,

alias stopnow='sudo poweroff'

That would enable you to shutdown the system by only running stopnow in terminal.

share|improve this answer
sudo init 0 may be a faster command, but would skip the notifying users and wont stop applications that are running, which may be bad. –  dash-plus-java Dec 12 '13 at 15:05
This command won't do anything anyway without a time: shutdown: time expected And to shutdown you need the -h option. And this can sometimes take a long time which I don't always have. –  ike Dec 12 '13 at 15:10
As in the linked answer: sudo poweroff should be quite fast and safe. I use it a lot when testing @#$% kernel boot parameters... –  Rmano Dec 12 '13 at 16:46
@ike Yikes! On my laptop is more around 10 seconds. Have you tried the sudo init 0 suggestion? It is not clean but cleaner than the Magic SysRQ. See also superuser.com/questions/108704/how-to-shutdown-instantly –  Rmano Dec 12 '13 at 17:15
No, it's not safe --- nothing short of the correct shutdown is safe. Maybe the OP should try to see why poweroff is so slow? –  Rmano Dec 12 '13 at 17:32
show 9 more comments

Alt+Print Screen+R,E,I,S,U. Then Power Button to shut down.

Will quickly and safely shut down a computer running Linux (Ubuntu). It is talking directly to the kernel, and can be used at anytime.

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

This is a modified version of REISUB. Since we don't want a restart, B is replaced with just shutting the computer down.

share|improve this answer
This will restart, not poweroff. –  Jobin Dec 12 '13 at 14:43
ok, so I guess replace B with O then to shut down? I'm not going to try it because I don't need to, but the Wikipedia article says that will shut it down. –  dash-plus-java Dec 12 '13 at 14:46
This is in short "Reboot Even If System Utterly Broken". It is not going to shutdown the system. –  souravc Dec 12 '13 at 14:52
I don't think this is minimizing the damage, on the contrary, this should only be used when the system is not responding. Killing processes is never good. And even when using this key combo we should wait a few secs between pressing those keys. (let the processes which can terminate safely before we SIGKILL them, wait for the sync before we unmount, etc.) –  falconer Dec 12 '13 at 15:13
@Dash_plus_Java why don't you edit your answer, it is not actually an answer to the question. isn't it? –  souravc Dec 12 '13 at 15:46
show 7 more comments

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.