Ubuntu在通过ssh关机之前显示警告

好,我承认…

我愚蠢closures我的远程服务器通过SSH而不是重新启动它,就像我想做的:(

为了防止我再次做傻事,有没有办法显示closures命令的警告/确认? (比如“你确定要closures这台服务器?”是/否)

或者,我可以不允许通过sshclosures(但不能重新启动,因为我可能还需要这样做)

尝试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”

你可以使一个规则总是通过时间参数来closures:

 # shutdown -h +2 

然后你可以在2分钟内取消关机:

 # shutdown -c 

不需要设置别名。 在Linux上,“rebo​​ot”命令是相当标准的。 停止使用关机命令…使用reboot