What does masking a service do?

What does masking a service do?

Masking a service prevents the service from being started manually or automatically. For this example, systemctl is creating a symlink from /etc/systemd/system/sshd. systemd recognizes the symlink and will not start the service.

How do I unmask a service in Linux?

Follow the steps below:

  1. systemctl edit systemd-hostnamed.
  2. This will create an override.conf file with the above 2 lines in the directory: /etc/systemd/system/systemd-hostnamed.service.d/
  3. The update systemd: systemctl daemon-reload.
  4. Then restart the service: systemctl restart systemd-hostnamed.

What is masking in systemd?

Masking a systemd unit is used to prevent the unit from starting. When a mask is set on a unit, a symbolic link with the name of that unit is created in the /etc/systemd/system directory which points to /dev/null.

Which command is used to remove masking on a service?

systemctl command
That’s nice.. how to unmask We can manage masking and unmasking using systemctl command in linux. We can use below command to unmask and start a service. Basically Masking is good way to prevent to accidental start of a service, we can unmask it, when required.

How to unmask a service whose unit file is empty?

While systemctl mask works by symlinking the service to /dev/null, systemd appears to just check if a file is 0 bytes when read to determine if a unit is masked. This results in the misleading message about a masked service. You need to figure out why the service unit is empty.

How to manage service masking and unmasking in Linux?

We can manage masking and unmasking using systemctl command in linux. We can use below command to unmask and start a service. Basically Masking is good way to prevent to accidental start of a service, we can unmask it, when required. This will help us in securing and optimising OS resources.

When does unmask fail in systemd-systemctl?

It seems the unmask command fails when there is no existing unit file in the system other than the symlink to /dev/null. If you mask a service, then that creates a new symlink to /dev/null in /etc/systemd/system where systemd looks for unit files to load at boot. In this case, there is no real unit file.

What happens when you mask a service in systemd?

If you mask a service, then that creates a new symlink to /dev/null in /etc/systemd/system where systemd looks for unit files to load at boot. In this case, there is no real unit file.