[Linux] Linux关机命令

shutdown命令

可以在终端输入shutdown --help或者man shutdown来查看:

@ubuntu:~$ shutdown --help
shutdown [OPTIONS...] [TIME] [WALL...]

Shut down the system.

     --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
  -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
@ubuntu:~$ 

或者man shutdown可以查看更加详细的操作说明。
除以上这些参数外,还有一些,共总结如下

-H: (halt)表示关闭设备
-P: 关机
-h: 等同于-P
-k: 仅发送警告消息给登录用户,不真正关机(仅仅root用户可用)
-c: 取消关机
-t mins: 过几分钟关机,默认1分钟。
-f:关机再次开机后,略过fsck磁盘检查
-F:关机再次开机后,强制进行fsck磁盘检查
halt和shutdown区别
  • 1.halt可以在不理会目前系统状况下,进行硬件关机的特殊功能;
  • 2.shutdown根据目前的启动的服务,在逐次关闭各个服务后才进行关机;
  • 3.halt会先调用shutdown,而shutdown最后会调用halt。

如:

# 得到当前时间
@ubuntu:~$ date
Tue Jun 12 16:14:15 PDT 2018
# 十分钟后关机
@ubuntu:~$ shutdown -t 10
Shutdown scheduled for Tue 2018-06-12 16:24:18 PDT, use 'shutdown -c' to cancel.
# 十分钟后关机
@ubuntu:~$ shutdown -h 10
Shutdown scheduled for Tue 2018-06-12 16:24:31 PDT, use 'shutdown -c' to cancel.
# 在20:00关机
@ubuntu:~$ shutdown -t 20:00
Shutdown scheduled for Tue 2018-06-12 20:00:00 PDT, use 'shutdown -c' to cancel.
# 在20:00关机
@ubuntu:~$ shutdown -h 20:00
Shutdown scheduled for Tue 2018-06-12 20:00:00 PDT, use 'shutdown -c' to cancel.
# 不执行关机,仅发送警告消息,必须root用户
@ubuntu:~$ shutdown -k now "system will power off"
Must be root.
遗留问题

在执行shutdown -H时,出现以下错误:

@ubuntu:~$ shutdown -H 
Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Action org.freedesktop.login1.halt is not registered
@ubuntu:~$ 

reboot、poweroff、halt命令

这三个命令使用方式完全一样,可以通过man reboot或者reboot --help可查看具体的说明。
如:

$ reboot             重启
$ reboot -p          重启
$ poweroff --reboot  重启
$ poweroff           关机
$ halt -p            关机
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值