Well, if you are a command line geek then you have probably often entered the wrong commands many times, some of which could lead to accidental shutdown/restart. Molly-Guard is a command line script which prevents you from accidentally shutting down or rebooting your Ubuntu system.
It basically overrides the default system binaries of the shutdown, reboot, or halt processes. So once you try to reboot or shutdown your system form the command line it will prompt you to enter the hostname of your computer. Thus in this way you are prevented from accidental shutdown or reboot.
Installing this script is a piece of cake, open the terminal and run the following command:
sudo apt-get install molly-guard
Once the installation is over, try to reboot your system, you will get the message to enter the hostname of your machine to proceed.
Here is what happened with me when I attempted to reboot my Ubuntu laptop after installing the script.
Ubuntu-lap:~$ sudo reboot
W: molly-guard: SSH session detected!
Please type in hostname of the machine to reboot: