为什么某些系统服务处于“屏蔽”状态?
当我运行命令sudo systemctl list-unit-files
(我认为sudo是可选的)时,我得到输出,显示所有服务及其状态。
这是我机器的一个片段:
UNIT FILE STATE ... debian-fixup.service static debug-shell.service disabled display-manager.service enabled dns-clean.service enabled dsmcad.service enabled emergency.service static failsafe-x.service static friendly-recovery.service masked fuse.service masked gdm.service masked getty-static.service static getty@.service enabled gpsd.service indirect gpsdctl@.service static gpu-manager.service enabled halt-local.service static halt.service masked hostname.service masked ...
我想知道为什么有些服务处于“蒙面”状态。 我认为这意味着,“这比’禁用’要好,因为服务无法通过手动或系统启动”。
如何获得有关服务单元状态的更多信息?
谁将这些单位置于各自的状态?
我试过,例如, sudo systemctl help dsmcad
– 只从单元文件中调出documentation = ...
行。 /etc/systemd/system/dsmcad.service
注意:这里我确切地知道dsmcad服务是什么以及它做了什么,我自己安装了它。 我对一般解决方案更感兴趣。
mask
是一个更强大的disable
版本。 使用disable
指定单元文件的所有符号链接将被删除。 如果使用mask
则单元将链接到/dev/null
。 如果您通过systemctl status halt.service
检查,则会显示此systemctl status halt.service
。 mask
的优点是防止任何类型的激活,甚至手动。
注意: systemctl list-unit-files
列出了单元文件的状态(静态,启用,禁用,屏蔽,间接),与服务状态无关。 要查看服务,请使用systemctl list-units
。
hostname.service
被屏蔽为冗余,因为systemd
在启动期间很早就设置了主机名(来自/ etc / hostname)。
此设置由Debian systemd软件包提供。
$ ls -l /lib/systemd/system/hostname.service lrwxrwxrwx 1 root root 9 Apr 8 22:47 /lib/systemd/system/hostname.service -> /dev/null $ dpkg-query --search /lib/systemd/system/hostname.service systemd: /lib/systemd/system/hostname.service
同样,Debian现在可以在没有shell脚本的情况下运行来halt
系统,它由systemd-shutdown ( 这里是源代码)处理。
如果已手动屏蔽服务,则掩码将安装在/etc/systemd/system
。
在Debian / Ubuntu上删除服务时也会屏蔽服务 。 我不知道为什么。