I am building a PC and a BeagleBords ARM embedded for public use. They run Ubuntu 13.04 and manually assembled Linux respectively. Is there a way to prevent them from being shut down on pressing Shutdown button (on case, not on keyboard)? Sure, I can do it in hardware. I just prefer software solutions. If somebody can say for sure "this is impossible" it would be a useful answer too.

Result: Ok, I understood it. One can prevent shutdown on press, but not on long press. I will have to make hardware switch to plug off Power button when needed.

  • Do you need to prevent deliberate or accidental key presses? Note that there are usually other ways to reboot/ shutdown a system including Magic SysReq (can be disabled) and switching to TTY and then reboot with Ctrl-Alt-Delete.
    – Lekensteyn
    Commented Jul 15, 2013 at 19:26
  • user173876 mentioned something (in a non-answer answer that we deleted) that may merit consideration: I have several time encountered situations (in my case during a GIMP operation) when all the screen launchers AND the keyboard became unresponsive, including Ctl-Alt-T, Alt-F1...F6, Ctl-Alt-Del, Ctl-Alt-BkSp, and the ONLY recourse was to use the power button to shutdown/restart. Removing this ability may leave you with having to remove the battery and/or pulling the power cord. Or smashing it with a hammer. Commented Jul 28, 2013 at 20:40

3 Answers 3


You can use next command in terminal:

sudo chmod -x /sbin/shutdown

If you want to re-enable, use +x instead -x in the same command.

Anyway, by holding the power button down for several seconds the above solution will not work and I don't think that you will find a software solution for this case.

  • You should use dpkg-statoverride to keep the permissions persistent through an upstart upgrade. Example: sudo dpkg-statoverride --add root root 0644 /sbin/shutdown. It must be noted though, that removing the execute permissions breaks the shutdown option for all users of this program (including poweroff and halt).
    – Lekensteyn
    Commented Jul 15, 2013 at 19:17

It is impossible. You need to physically keep the public away from the power switch, just as you need to prevent them from yanking the power cord from the wall, or grabbing the whole machine and running off with it.

  • I'm not convinced that it is impossible. The software is responsible for initiating shutdown. How would your desktop otherwise get the chance of showing the shutdown menu or gracefully terminating programs?
    – Lekensteyn
    Commented Jul 15, 2013 at 19:10
  • @Lekensteyn, it isn't when you hold down the button for 4 seconds.
    – psusi
    Commented Jul 15, 2013 at 19:15
  • Five seconds, isn't it? That is indeed a switch that is not overridable, but pressing (... and release it immediately) the shutdown button once is handled by ACPI which means that it can be intercepted and ignored. You are correct though, it is likely that the OP is considering deliberate attempts to shutdown the system.
    – Lekensteyn
    Commented Jul 15, 2013 at 19:21

You need to alter...


and comment out this line (I already added the #) ...

#/sbin/shutdown -h now "Power button pressed"
  • This only affects the power button and not the shutdown from the menu.
  • But also note bug 1124149 that claims that due to a move from /usr/bin/qdbus to /usr/lib/i386-linux-gnu/qt4/bin/qdbus it might not always work (bug also affects Ubuntu).
  • This solution doesn't have any effect on my system. Commented Jul 15, 2013 at 15:20
  • That will be the bug @RaduRădeanu :) It works on 12.10 at work; and also not on my machine at home(that has 13.04). So for the mean time use Radu's method but that probably also affects other buttons on the keyboard.
    – Rinzwind
    Commented Jul 15, 2013 at 16:49
  • That won't stop holding down the power button for 4 seconds ;)
    – psusi
    Commented Jul 15, 2013 at 18:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .