Mask 不能启动的服务

在一台很久不用Web 的 Ubuntu 上设置 Apache, 看到题示的错误,只要运行
systemctl unmask apache 即可,实际上主要原因是因为系统安装的 Web 是 Nginx 不是 Apache。

mask 的概念:
We saw in the service management section how to stop or disable a service, but systemd also has the ability to mark a unit as completely unstartable, automatically or manually, by linking it to /dev/null. This is called masking the unit, and is possible with the mask command:
翻译过来就是 mask 的服务, 不允许自动或者手工启动。

systemctl list-units –all
systemctl list-unit-files
systemctl list-units –all –state=inactive

systemctl cat atd.service
systemctl list-dependencies sshd.service
systemctl show sshd.service
systemctl show sshd.service -p Conflicts

systemctl edit nginx.service
systemctl edit –full nginx.service
rm -r /etc/systemd/system/nginx.service.d
rm /etc/systemd/system/nginx.service
systemctl –failed
reset 有错的服务: systemctl reset–failed
每次编辑或者删除服务文件需要做 daemon-reload:
systemctl daemon-reload

systemctl get-default
systemctl set-default
systemctl list-unit-files –type=target
systemctl list-units –type=target
systemctl list-dependencies
systemctl isolate

放到 rescue/halt/poweroff 模式:
systemctl rescue
systemctl halt
systemctl poweroff
systemctl reboot

作者: 甬洁网络