一、systemctl理解
Linux 服务管理两种方式service和systemctl
systemd是Linux系统最新的初始化系统(init),作用是提高系统的启动速度,尽可能启动较少的进程,尽可能更多进程并发启动。
systemd对应的进程管理命令是systemctl
1. systemctl命令兼容了service
即systemctl也会去/etc/init.d目录下,查看,执行相关程序
systemctl redis start
systemctl redis stop
# 开机自启动
systemctl enable redis
2.常见命令
foobar表示伪变量。
打开服务:sudo systemctl start foobar
关闭服务:sudo systemctl stop foobar
重启服务:sudo systemctl restart foobar
不中断正常功能下重新加载服务:sudo systemctl reload foobar
设置服务的开机自启动:sudo systemctl enable foobar
关闭服务的开机自启动:sudo systemctl disable foobar
查看活跃的单元:systemctl list-units
查看某个服务的状态:systemctl status foobar
查看已启动的服务列表: systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
参考链接:技术|systemctl 命令完全指南