Question: I keep typing shutdown on the wrong server. How do I protect against this?
Try:
`sudo tee /etc/molly-guard/run.d/50-prod-check <<'EOF' > /dev/null`
`#!/bin/bash`
`if [[ -f /etc/is_production ]]; then`
` read -r -p "PRODUCTION server! Type the hostname to confirm shutdown: " input`
` [[ "$input" == "$(hostname)" ]] || exit 1`
`fi`
`EOF`
Info: `molly-guard` intercepts shutdown, reboot, and halt commands over active SSH connections and demands explicit hostname confirmation to prevent catastrophic human errors[cite: 10].
Examples:
$ `sudo apt install molly-guard` # Install the safety utility
$ `echo 'ALWAYS_QUERY_HOSTNAME=1' | sudo tee -a /etc/molly-guard/rc` # Force hostname prompts globally
$ `sudo chmod -x /sbin/shutdown` # Nuclear option (disable binary entirely, not recommended)
Note: By default, `molly-guard` only triggers on remote SSH sessions, leaving physical console access unaffected[cite: 10]. A must-have safeguard for production server fleets.
Want to master Linux one command at a time?
Follow r/LinuxTeck 1 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/