Linux 拦截 reboot 命令

拦截用户输入的 reboot
命令,防止手滑输入成reboot导致服务器重启,连选择的机会都没有
(之前在公司,一同事要重启apache,结果就敲成了 reboot... 那台服务器上运行了好多公司重要服务。瘫痪了10分钟
把下面代码写入到 /etc/profile
内,并执行一次 source /etc/profile
# 自定义一个 func
sendya_reboot() {
while true
do
echo -n "You really want to restart the server? (yes/no):"
read crm
if [ "$crm"x = "yes"x ]; then
echo "rebooting"
\reboot
else
break
fi
break
done
}
# 别名
alias reboot='sendya_reboot'
效果