Image of Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
Image of Modern Operating Systems (3rd Edition)
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)
Image of XSLT 2.0 and XPath 2.0 Programmer's Reference (Programmer to Programmer)

Mask V Disable a Systemd Service Unit

In the systemd world, you should be aware of the difference between disabling and masking a service unit.

To prevent a service unit that corresponds to a system service from being automatically started at boot time:

# systemctl disable name.service

When invoked systemd reads the [Install] section of the selected service unit and removes the appropriate symbolic link. In RHEL7, for example, the symbolic link would be to the /usr/lib/systemd/system/name.service file from the /usr/lib/systemd/system/ directory.

Every service unit that is known to systemd may be started if it is needed – even if it is disabled. To explicitly tell systemd that a service should never run, you have to use the mask command:

# systemctl mask name.service

This command replaces the /etc/systemd/system/name.service unit file with a symbolic link to /dev/null, rendering the actual unit file inaccessible to systemd.

To revert this action and unmask a service unit:

# systemctl unmask name.service

1 comment to Mask V Disable a Systemd Service Unit

  • remd

    useful article. However I have a service that is masked and when I unmask it is stays masked, also after a reboot. Do you know of any reasons why it won’t unmask ?