Don’t let users reboot while root’s logged in

rebootshutdown

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

Best Answer

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
Related Question