In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use molly-guard to protect your Linux/Unix machine from being mistakenly shut down / restarted, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Molly-Guard tries to prevent you from accidentally shutting down or restarting the Linux server. Its package description in Debian/Ubuntu is as follows:
This package installs a shell script to block existing shutdown/reboot/halt/poweroff/coldreboot/pm-hibernate/pm-suspend* commands. Molly-gurad will first run a series of scripts, and the real command will be called only if all scripts return success. One of the scripts checks for the existence of a SSH session. If the command is called through a SSH session, the shell script will prompt you to enter the name of the shutdown host. This should be enough to prevent you from accidentally shutting down or rebooting.
It seems that molly-guard is also a proper noun Jargon File:
A barrier used to prevent clumsiness or carelessness from touching the road red switch. Originally referred to as the plexiglass that was temporarily covered with the bright red button of IBM 4341, because a programmer's toddler daughter (named Molly) restarted it twice in one day. Later, it was also used to cover the stop / restart buttons on disks and network devices. You rarely see such a boring description as "guarded button" in the hardware catalog.
How to install molly guard
Use the apt-get command or the apt command to search for and install molly-guard:
$apt search molly-guard$ sudo apt-get install molly-guard
The result is:
Fig.01: Installing molly guard on Linux
Test it
Enter the reboot command and shutdown command:
$sudo reboot# reboot$ shutdown-h "sudo shutdown-h 0mm" # running wrong command such as follows instead of### sudo virsh reboot vm_name_here$ sudo reboot vm_name_here
The result is:
Fig.02: Molly guard saved my butt;\)
I love molly-guard. So I added the following line to the apt-debian-ubuntu-common.yml file:
-apt: name: molly-guard
Right. I use Ansible to install it automatically on all Debian and Ubuntu servers.
Related: my top 10 UNIX command line errors
What if my Linux distribution or Unix system (such as FreeBSD) doesn't have molly-guard?
Don't be afraid, set the shell alias:
# # bash shell example # alias reboot = "echo 'Are you sure?' If so, run / sbin/reboot" alias shutdown = "echo' Are you sure?' If so, run / sbin/shutdown"
You can also temporarily cancel the alias mechanism to run the real command. For example, to run reboot, you can do this:
#\ reboot
Or
# / sbin/reboot
Alternatively, you can write a shell/perl/python script to invoke these commands and ask to confirm the options for reboot/halt/shutdown.
The above is all the contents of the article "how to use molly-guard to protect your Linux/Unix machine from being shut down / restarted incorrectly". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.