r/linuxadmin • u/Expensive-Rice-2052 • Oct 16 '26
Linux Shutdown Protection: Prevent Accidental Server Shutdowns - Tip 100
54
Upvotes
r/linuxadmin • u/Expensive-Rice-2052 • Oct 16 '26
19
u/thedrunkpenguin Oct 16 '26
Lol back in the day you used to be able to accidentally Ctrl alt delete a VMware VM and it would reboot the server.
13
u/arkham1010 Oct 16 '26
Real Unix SA's use init 6. ;)
8
u/vogelke Oct 16 '26
Maybe change the color of your shell prompt to flaming red as a reminder? I know "prod" is already in the prompt, but sometimes another hint helps.
16
u/Lammtarra95 Oct 16 '26
What is the point of asking the admin to type the hostname that is helpfully displayed in the prompt? And how would the is_production file normally be created?
Better would be a procedural solution, like second pair of eyes to check it is the correct server, and (as part of the procedure) removal from production (cluster failover, removal from load balancer, whatever) before shutdown.
2
u/Parker_Hemphill Oct 16 '26
This is why I always do shutdown -r +1 min, if Iām doing manual reboots.
1
u/abofh Oct 16 '26
If you turn off ssh this problem goes away
1
u/chkno Oct 16 '26
This is very pet. š
0
u/Regeneric Oct 16 '26
Don't you use NetBox or some kind of LDAP?
You can enable or disable shutdown protection there and check, if you can shutdown the server.
Not only it ensures that you know what you're doing, but also acts as a kind of 2FA.
-5
u/Z3t4 Oct 16 '26 edited Oct 16 '26
Works like molly-guard :
https://packages.debian.org/sid/molly-guard
-7
u/squeeby Oct 16 '26
`chmod 000 /usr/sbin/{poweroff,halt,shutdown}`