9

On my system users can reboot and shut down the system. From time to time I need to update software (or do anything else) and I don't want users to reboot/shutdown the system until I've finished.

Is there a way to prevent system from rebooting/shutting down while root is logged in (locally or over SSH)?

  • How will you ever prevent people from using the brute force method? – Bernhard Oct 20 '13 at 13:26
  • @Bernhard probably something with /etc/acpi/powerbtn.sh – PMint Oct 20 '13 at 19:51
11

Try Molly guard:

$ sudo apt-get install molly-guard

This package will prevent unintended shutdown/reboot/suspend/hibernate by interactively prompting you to enter the hostname of the system.

However, it's trivial to configure molly-guard to completely disable shutdown/reboot/suspend/hibernate. Simply create an executable file at /etc/molly-guard/run.d/99-prevent-all that has this in it:

#!/bin/sh
exit 1

(You didn't mention the OS, this is for Ubuntu).

History

If you're curious the term molly-guard is what the cover over a red button is called. See the wikipedia article on Big Red Button if you're curious.

excerpt

A Big Red Switch often includes a molly-guard, a cover that must be lifted to trip the switch. The original molly-guard was jury-rigged from Plexiglas to prevent a programmer's young daughter Molly from pressing the BRS on an IBM 4341 server, after she had done so twice in one day.

Other distros

You can take the .deb package and use alien to convert it to an RPM suitable for Fedora/RHEL/CentOS.

$ sudo yum install alien
$ alien -r molly-guard*.deb
  • 1
    +1 never heard of this tool, will be installing it on several serers 8-). – slm Oct 20 '13 at 13:23
  • 1
    Really neat tool. For the sake of the specific question and completeness, might specify for root's .bashrc / .bash_logout to enable/disable the all-stop. A conditional in the molly-guard script checking for UID!=0 might also be appropriate. – Joshua Miller Oct 20 '13 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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