关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

云服务器linux设置拦截reboot命令

发布时间:2023/12/6 13:15:01
香港云服务器

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'