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

Image: iStock

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.

Image: Spandas Lui/Lifehacker

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.

[nixCraft]


Comments

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

    apt-get? Only if you are on a Debian-like distibution such as Debian or Ubuntu. Certainly not on Unix, or Gentoo, or RHEL, or Centos or ...... the list is endless.

      because it's not available on other package managers. you can use shell aliases to accomplish the same thing, the tool is a good quick fix.

Join the discussion!

Trending Stories Right Now