systemctl and service, chkconfig common commands Comparative

Foreword

  • systemctl service management system is RHEL instructions 7, before it is fused and chkconfig service functions in one, is a collection of service and replaced chkconfig command and command. You can use it permanently or only enable / disable service in the current session
  • CentOS is based on one of RHEL (RedHat Enterprise Linux) Linux distributions, CentOS 7 also use systemctl, replacing the service and chkconfig, you will be redirected to use the equivalent of two systemctl command after command in CentOS 7
  • To serve as an example sshd.service

systemctl commonly used commands

列出所有服务:systemctl list-unit-files --type=service
列出服务层级和依赖关系:systemctl list-dependencies sshd.service

显示服务状态:systemctl status sshd.service
启动服务:systemctl start sshd.service
关闭服务:systemctl stop sshd.service
重启服务:systemctl restart sshd.service

设置服务开机自启动:systemctl enable sshd.service
禁止服务开机自启动:systemctl disable sshd.service

查看服务是否自启动:systemctl is-enabled sshd.service
列出系统所有服务的启动情况:systemctl list-units --type=service
列出所有自启动服务:systemctl list-unit-files|grep enabled

service, chkconfig commonly used commands

显示服务状态:service sshd status
启动服务:service sshd start
关闭服务:service sshd stop
重启服务:service sshd restart

设置服务自启动:chkconfig --level 3 sshd on
禁止服务自启动:chkconfig --level 3 sshd off

查看服务是否自启动:chkconfig --list sshd
列出系统所有服务的启动情况:chkconfig --list

References:

Linux - using the command management services systemctl
difference between Linux under systemctl command and service, chkconfig command


End~

Published 15 original articles · won praise 5 · views 10000 +

Guess you like

Origin blog.csdn.net/TomAndersen/article/details/104237056