最近玩Linux发现了systemctl这个命令,不管是Ubuntu还是Centos还是其他的发行版都有这个命令,其实这个命令早就存在了,相当于将service和chkconfig命令整合到一起了,实际上systemctl不仅仅包含service和chkconfig的功能,还有其他的功能,本文仅讨论systemctl与service,chkconfig的关系
systemctl与service对比
daemon命令 | systemctl命令 | 说明 |
---|---|---|
service [服务] start | systemctl start [unit type] | 启动服务 |
service [服务] stop | systemctl stop [unit type] | 停止服务 |
service [服务] restart | systemctl restart [unit type] | 重启服务 |
例:
#启动Apache
systemctl start httpd.service
#停止Apache
systemctl stop httpd.service
#重启Apache
systemctl restart httpd.service
#查看Apache状态
systemctl status httpd.service
systemctl与chkconfig对比
daemon命令 | systemctl命令 | 说明 |
---|---|---|
chkconfig [服务] on | systemctl enable [unit type] | 设置服务开机启动 |
chkconfig [服务] off | systemctl disable [unit type] | 设备服务禁止开机启动 |
例:
#设置Apache开机启动
systemctl enable httpd.service
#禁止Apache开机启动
systemctl disable httpd.service