Linux 设置关机重启提示

Linux 设置关机重启提示

由于运行 reboot 命令系统默认不需要输入密码,为了防止意外发生,必须设置关机提示。

编辑 .zshrc

1
$ vi ~/.zshrc

注意,如果使用 bash 的话,请编辑 .bashrc 文件。

追加内容

1
2
3
# Shutdown and restart confirmation
alias shutdown="echo 'Are you sure?' If so, run /sbin/shutdown"
alias reboot="echo 'Are you sure?' If so, run /sbin/reboot"

更新文件

1
$ source .zshrc

到此,每当运行 reboot 或者 shutdown 命令的时候,都会出现提示。
这只是其中一种笨方法,但是很简单。

赞赏