systemctl 查看当前已安装服务(取代 chkconfig)

命令说明
systemctl列出所有的系统服务
systemctl list-units列出所有启动 unit
systemctl list-unit-files列出所有启动文件
systemctl list-units --type=service --all列出所有 service 类型的 unit
systemctl list-units --type=service --all grep cpu列出 CPU 电源管理机制的服务
systemctl list-units --type=target --all列出所有 target
systemctl list-unit-files列出所有的系统服务
systemctl is-active [unit type]查看服务是否运行
systemctl is-enable [unit type]查看服务是否设置为开机启动
systemctl mask [unit type]注销指定服务
systemctl unmask [unit type]取消注销指定服务

删除系统服务

1
2
3
4
5
6
systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /usr/lib/systemd/system/[servicename]
systemctl daemon-reload
systemctl reset-failed

注意事项: 如果有必要,在执行 systemctl reset-failed 之前删除 /etc/init.d/[servicename]。想找到要删除的所有单位文件,可以使用 systemctl cat 命令。