Ubuntu
Ubuntu 在通過 ssh 關閉之前顯示警告
好吧我承認…
我愚蠢地通過 ssh 關閉了我的遠端伺服器,而不是像我想做的那樣重新啟動它:(
為了防止我再次做傻事,有沒有辦法在關機命令上顯示警告/確認?(例如“您確定要關閉此伺服器嗎?”是/否)
或者,我可以不允許通過 ssh 關閉(但不能重新啟動,因為我可能仍然需要不時這樣做)?
嘗試
molly-guard
:protects machines from accidental shutdowns/reboots
您可以為您的帳戶中的關閉命令設置別名,編輯
/home/username/.bashrc
添加
function savemefromlookingstupid(){ echo 'Are you sure you wanna SHUTDOWN? [n]' read yesno if [ $yesno == y ]; then sudo /usr/sbin/shutdown -h now exit 1 fi echo 'Thought so.. watch it, that was close..' } alias restart_server='sudo /user/sbin/shutdown -r now' alias shutdown='savemefromlookingstupid'
要重新啟動,您將執行“restart_server”