197 字
1 分钟
Linux 彻底删除 Systemctl 服务
特别注意本文所有命令中的 test.service 需替换成实际需要删除的服务名称
1、停止服务
# 停止服务sudo systemctl stop test.service2、禁用开机启动
sudo systemctl disable test.service3、删除服务文件
sudo rm -f /etc/systemd/system/test.service或
sudo rm -f /lib/systemd/system/test.service提示上面是服务文件的常见路径,具体路径可通过下面的命令查看
Terminal window sudo systemctl status test.service
4、重新加载 Systemd 配置
sudo systemctl daemon-reloadsudo systemctl reset-failed5、验证服务已删除
systemctl status test.service # 应该显示 "Unit test.service could not be found"6、依赖关系清理
如果服务有依赖关系(如定时器、其他服务),也需要一并删除
systemctl list-dependencies test.service # 查看依赖7、日志清理
sudo journalctl -u test,service # 查看服务日志sudo journalctl --vacuum-time=1s --unit=test.service # 清除服务日志 Linux 彻底删除 Systemctl 服务
https://dyh1319.asia/posts/linux-delete-systemctl-service/