Linux 为reboot等敏感命令执行时添加提示确认信息(防止误重启)
- 编辑/etc/profile文件,添加以下代码:
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'
最终效果如下:
root@VM]$ reboot
You really want to restart the server? (yes/no):