systemctl

2018-07-03 浏览 (1402)

systemctl是用来管理linux系统启动和系统服务的相关命令集,从CentOS 7.x开始,CentOS开始使用systemd服务来代替daemon,systemd 相关的绝大多数任务都是通过 systemctl 命令管理。

systemd即为system daemon,是linux下的一种init软件,由Lennart Poettering带头开发,并在LGPL 2.1及其后续版本许可证下开源发布,开发目标是提供更优秀的框架以表示系统服务间的依赖关系,并依此实现系统初始化时服务的并行启动,同时达到降低Shell的系统开销的效果,最终代替现在常用的System V与BSD风格init程序。

与多数发行版使用的System V风格init相比,systemd采用了以下新技术:

(1) 采用Socket激活式与总线激活式服务,以提高相互依赖的各服务的并行运行性能;

(2) 用Cgroups代替PID来追踪进程,以此即使是两次fork之后生成的守护进程也不会脱离systemd的控制。

systemctl 与旧命令的一些比较:

任务                    旧指令                            新指令

使某服务自动启动        chkconfig --level 3 httpd on    systemctl enable httpd.service

使某服务不自动启动        chkconfig --level 3 httpd off    systemctl disable httpd.service

检查服务状态            service httpd status            systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)

显示所有已启动的服务    chkconfig --list                systemctl list-units --type=service

启动某服务                service httpd start                systemctl start httpd.service

停止某服务                service httpd stop                systemctl stop httpd.service

重启某服务                service httpd restart            systemctl restart httpd.service

系统关机                init 0                             systemctl poweroff     

重新启动                init 6                             systemctl reboot     

防火墙使用样例:

systemctl status firewalld.service

systemctl stop firewalld.service          

systemctl disable firewalld.service

  • 所属分类: linux
  • 版权声明: 本文链接 https://seaxiang.com/blog/linux_systemctl