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)?

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

1 Answer 1

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
2
  • 1
    +1 never heard of this tool, will be installing it on several serers 8-).
    – slm
    Commented Oct 20, 2013 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. Commented Oct 20, 2013 at 19:59

You must log in to answer this question.

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