Centos7之后服务的启动方式从init完全换成了systemd的启动方式,systemd 启动服务的机制主要是通过 systemctl 的这个系统服务管理指令来处理。
![图片[1]-Linux systemctl命令:管理系统服务-编程社](https://cos.bianchengshe.com/wp-content/uploads/2023/06/u9707830092150058000fm253fmtautoapp138fJPEG.webp?imageMogr2/format/webp/interlace/1/quality/100)
语法格式:systemctl [参数] [服务]
常用参数:
-start | 启动服务 |
-stop | 停止服务 |
-restart | 重启服务 |
-enable | 使某服务开机自启 |
-disable | 关闭某服务开机自启 |
-status | 查看服务状态 |
-list -units –type=service | 列举所有已启动服务 |
参考实例
启动httpd服务:
[root@bianchengshe ~]# systemctl start httpd.service
停止httpd服务:
[root@bianchengshe ~]# systemctl stop httpd.service
重启httpd服务:
[root@bianchengshe ~]# systemctl restart httpd.service
查看httpd服务状态:
[root@bianchengshe ~]# systemctl status httpd.service
使httpd开机自启:
[root@bianchengshe ~]# systemctl enable httpd.service
取消httpd开机自启:
[root@bianchengshe ~]# systemctl disable httpd.service
列举所有已启动服务(unit单元) :
[root@bianchengshe ~]# systemctl list-units --type=service
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容