Ubuntu shutdown 命令详解


shutdown 可用于安全关闭 重启 停止计算机。 此时会被冻结 login 指令,新用户不能再登录。

shutdown 命令需有 root 权限, shutdown 是把信号发送给 init 命令,要求 init 改变 runlevel,以此进行相关操作。

关机或重启计算机实际上是 runlevel 的调整, 因此,也可使用 init 命令 (需 root 权限) 直接调整 runlevel 进行相关操作。

Linux 系统后台通常运行着许多进程, 强制直接关闭计算机电源可能导致进程数据丢失, 使系统处于不稳定状态 (甚至损坏硬件设备)。

另请参阅: halt     poweroff     reboot

基本语法     基本用法


shutdown [OPTIONS...] [TIME] [WALL...]
			

OPTIONS 选项

参数 EN 解释 中文翻译 备注
--help Show this help 展示相关帮助信息
-H --halt Halt the machine 停止机器
-P --poweroff Power-off the machine 关闭机器电源
-r --reboot Reboot the machine 重新启动机器
-h Equivalent to --poweroff, overridden by --halt 等效于 --poweroff,由 --halt 覆盖 杀死应用进程,执行 sync 系统调用文件系统写操作后停止内核
-k Don't halt/power-off/reboot, just send warnings 不停止/关机/重启,只发送警告
--no-wall Don't send wall message before halt/power-off/reboot 在停止/关机/重启前,不发送墙消息
-c Cancel a pending shutdown 取消挂起关机

基本用法

功能 命令 文字解释 示例 示例解释
帮助 shutdown --help 展示帮助信息
关机 shutdown -P time 倒数计时关闭计算机电源 shutdown -P +1 倒数 1 分钟关闭计算机电源
重启 shutdown -r minute 计时重启计算机 shutdown -r +1 倒数 1 分钟重启计算机
shutdown -r time 定时重启计算机 shutdown -r 20:35 20:35 时重启计算机
shutdown -r now 立即重启计算机
取消 shutdown -c 取消所有相关操作

 

版权声明: 本文为独家原创稿件,版权归 乐数软件 ,未经许可不得转载。