If a service is
enabled, then there is a symlink somewhere in
to a unit file, most often somewhere in
Helpfully, when you
enable a service, the full paths of the created link and target will be printed to stdout.
Disabling the service deletes the symlink, so the unit file itself is not affected, but the service is not loaded at the next boot, when systemd reads
However, a disabled service can be loaded, and will be started if a service that depends on it is started;
disable only configure auto-start behaviour for units, and the state is easily overridden.
A masked service is one whose unit file is a symlink to
/dev/null. This makes it "impossible" to load the service, even if it is required by another, enabled service.
mask a service, a symlink is created from
/dev/null, leaving the original unit file elsewhere untouched. When you
unmask a service the symlink is deleted.
However, I have noticed that these commands are not always honoured.
When I try to mask most services, it fails:
$ sudo systemctl mask bluetooth.service
Failed to execute operation: Invalid argument
Of course, I stopped the service first. @Anwar suggests masking is only possible for non-critical services.
Unmasking a masked service, unless I masked it myself, also fails (silently). I believe this is because there is no unit file for the service anywhere, except in the form of a symlink to
/dev/null, this time in
$ file $(locate fuse.service)
/lib/systemd/system/fuse.service: symbolic link to /dev/null
$ sudo systemctl unmask fuse.service
$ systemctl status fuse
Loaded: masked (/dev/null; bad)
Active: inactive (dead)
I'm not the only one having this problem
To actually unmask the masked service x11-common, I had to delete the symlink to
sudo apt-get install --reinstall x11-common && sudo systemctl daemon-reload. Now when I query it with
systemctl status x11-common I see the service has a nice green circle and is loaded and active (exited) although it has no unit file.
For further reference this article on How to Use Systemctl may be of some use.