欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > linux >内容正文

linux

linux7 chkconfig,centos 6-7 chkconfig -systemctl关系对比

发布时间:2024/9/27 linux 56 豆豆
生活随笔 收集整理的这篇文章主要介绍了 linux7 chkconfig,centos 6-7 chkconfig -systemctl关系对比 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

CentOS 7 已经切换到 systemd,系统指令也有所变化。之前用于启动、重启、停止各种服务的 service 作为向后兼容的指令还能使用,但是将来可能会消失。同时,chkconfig 也改成了 systemctl 了。这里列举了一些常用的对应于 service 和 chkconfig 的新的 systemctl 指令。

在目前的 CentOS 7(或 RHEL 7)系统中,依然可以使用 service 指令。例如,

[root@localhost ~]# service network restart

Restarting network (via systemctl): [ OK ]

[root@localhost ~]# service httpd restart

Redirecting to /bin/systemctl restart httpd.service

[root@localhost ~]# service sshd restart

Redirecting to /bin/systemctl restart sshd.service

但是系统会自动重定向该指令到新的指令 /bin/systemctl 来执行,并给出提示。

是时候切换到新的指令格式了,直接使用 systemctl 吧。这个指令的意思就是 system control。下面是一些常用的例子:

启动服务:

systemctl start httpd

停止服务:

systemctl stop httpd

重启服务(先停止,后启动):

systemctl restart httpd

重新加载(使用新的配置文件):

systemctl reload httpd

显示服务状态:

systemctl status httpd

与此同时,之前用于设定系统启动时自动运行某服务的指令 chkconfig 也改了,还是用 systemctl。

chkconfig service on

改成了,

systemctl enable httpd

chkconfig service off

改成了,

systemctl disable httpd

检查服务状态的

chkconfig service

改成了,

systemctl is-enabled httpd

列举出所有服务的指令,

chkconfig –list

改成了,

systemctl list-unit-files –type=service

以前能指定服务 runlevel 的 –levels 也没有了。慢慢适应吧。©

总结

以上是生活随笔为你收集整理的linux7 chkconfig,centos 6-7 chkconfig -systemctl关系对比的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。