Use Molly-Guard To Stop Accidental Shutdowns Or Reboots Of Your Linux Machine

If you are acquainted with the command line on Linux or Unix systems, you’ve probably punched in the wrong command by mistake more times than you’d care to admit. It’s particularly frustrating when that mistake concerns shutting down the wrong machine, which can happen when you’re SSHing into multiple virtual machines. molly-guard is a tool that prevents accidental shutdowns or reboots.

molly-guard is an oldie but a goodie, though some new Linux users may not be aware of its existence. nixCraft writer Vivek Gite recently started using molly-guard after accidentally executing the shutdown -h 0 command in the wrong terminal and ended up shutting down a database server instead of his home server. Those who have made similar mistakes know that it can be an infuriating experience.

molly-guard overrides commands associated with shutting down or restarting Linux/Unix machines including shutdown, reboot, halt and poweroff. When you try to invoke those commands and an SSH session is detected, molly-guard will spring into action and check that you’re trying to shutdown/reboot the right machine by asking for confirmation of the host name.

Bear in mind, molly-guard’s powers are limited to SSH sessions so it won’t help you if you’re on the host machine’s console but it is quite useful for those who often have to SSH into multiple virtual machines.

To get molly-guard on your Linux/Unix machine, use the apt-get install molly-guard command in the terminal.


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.


4 responses to “Use Molly-Guard To Stop Accidental Shutdowns Or Reboots Of Your Linux Machine”