技术知识库

帮助中心 >  产品文档 >  云服务器 >  linux设置拦截reboot命令

Linux 拦截 reboot 命令

拦截用户输入的 reboot 命令,防止手滑输入成reboot导致服务器重启



把下面代码写入到 /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'


image.png

提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: