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
  • 注意的一点(如果有必要)
    1
    2
    在systemctl reset-failed之前删除/etc/init.d/[servicename]
    想找到要删除的所有单位文件,可以使用systemctl cat