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 graphical.target
systemctl list-unit-files –type=target
systemctl list-units –type=target
隔离目标:
systemctl list-dependencies multi-user.target
systemctl isolate multi-user.target

设置重要事件:
放到 rescue/halt/poweroff 模式:
systemctl rescue
systemctl halt
systemctl poweroff
systemctl reboot

作者: 甬洁网络

--移动互联网&物联网技术提供商