centos6.x 与 centos7.x 关于 shutdown 的区别

默认动作

先来看看centos6.8的shutdown说明:

[root@localhost ~]# shutdown --help
Usage: shutdown [OPTION]... TIME [MESSAGE]
Bring the system down.

……
The system is brought down into maintenance (single-user) mode by default, you can change this with either the -r or -h option which specify a reboot or system halt respectively.

可以看出centos6.8的shutdown默认动作是进入单用户模式。若想真正地关机,需要添加 -h 选项。

在centos7中查阅shutdown手册:

[root@dev ~]# man shutdown
……
OPTIONS
……
       -P, --poweroff
           Power-off the machine (the default).
……

可以看到,centos7的shutdown默认动作是断电。所以在关机的时候就无需 -h 选项啦。

实现方式

centos6.8中shutdown是由单独的 upstart 包提供的:

[root@localhost ~]# which -a shutdown
/sbin/shutdown
[root@localhost ~]# ll /sbin/shutdown
-rwxr-xr-x. 1 root root 64496 May 11  2016 /sbin/shutdown
[root@localhost ~]# rpm -qf /sbin/shutdown
upstart-0.6.5-16.el6.x86_64

而在centos7中是却由 systemctl 来实现的:

[root@dev ~]# which -a shutdown
/usr/sbin/shutdown
[root@dev ~]# ll /usr/sbin/shutdown
lrwxrwxrwx. 1 root root 16 Oct 22 16:01 /usr/sbin/shutdown -> ../bin/systemctl
[root@dev ~]# rpm -qf /usr/bin/systemctl
systemd-219-67.el7.x86_64

至于为什么 systemctl 能表现出类似于两个指令的方式,是因为在 systemctl 执行时会对传入的指令名字进行判断,从而表现出不同的执行逻辑出来。具体参考:why-are-reboot-shutdown-and-poweroff-symlinks-to-systemctl
其实相关的 reboot、halt 等指令也是采用了这种实现方式。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值