Unit systemd-resolved.service is masked

6,379

Solution 1

If your service is masked it is symlinked to /dev/null
You can verify by:

ls -l /etc/systemd/system/systemd-resolved.service

To remove the mask simply run:

sudo systemctl unmask systemd-resolved

/lib/systemd/system/systemd-resolved.service is a text file and cannot be executed by bash. The service binary is located /lib/systemd/systemd-resolved

Solution 2

Try removing the systemd service file and then starting it again.

Remove the file-

sudo rm /lib/systemd/system/systemd-resolved.service

Reload the daemon

sudo systemctl daemon-reload

Once reloaded, start the service

sudo systemctl start systemd-resolved
sudo systemctl enable systemd-resolved

Note: For getting the location of systemd-resolved service you can use sudo systemctl enable systemd-resolved and further use the location for removing the file.

The masked systemd service made my system have issues with network manager and I was not being able to use internet on the system. When I checked further for errors or warnings using grep resolved /var/log/syslog command, I came across the error that this service is masked and unmasked it using the solution above.

Share:
6,379

Related videos on Youtube

zero_coding
Author by

zero_coding

Updated on September 18, 2022

Comments

  • zero_coding
    zero_coding over 1 year

    I was trying to restart the systemd-resolved.service with the command:

    sudo systemctl restart systemd-resolved
    

    and got the error message:

    Failed to restart systemd-resolved.service: Unit systemd-resolved.service is masked. 
    

    File the systemd-resolved.service exists in the folder /lib/systemd/system.

    The status of the service is:

    /lib/systemd/system# systemctl status systemd-resolved.service
    ● systemd-resolved.service
       Loaded: masked (/dev/null; bad)
       Active: inactive (dead)
    

    When I try to execute with:

    /lib/systemd/system/systemd-resolved.service
    -bash: /lib/systemd/system/systemd-resolved.service: Permission denied
    

    What am I doing wrong?

  • RomanK
    RomanK over 3 years
    What is the purpose of deleting the service file?
  • sheetal
    sheetal over 3 years
    @RomanK unmask didn't worked in my case, so I deleted the service first and then restarted it, and that worked! so I shared that here.
  • RomanK
    RomanK over 3 years
    If you will delete that Unit, the service cannot start unless you have drop-in in /etc/systemd/system/ or in other paths as per documentation. Removing the file is a bad advice.
  • sheetal
    sheetal over 3 years
    @RomanK But that was created by itself when i started the service. I don't have explored it that much, but after grinding for two days, this method worked for me and I shared it. I'll keep your advice in mind, thanks!