« Back to Systemd: Frequently Asked Questions

How to see all masked units with systemctl

How to see all masked systemd units?

Use systemctl with the 'list-unit-files' subcommand and filter out units that are in a state of 'masked'.

systemctl list-unit-files --state=masked

Systemd uses the concept of masked units that prevents those units from being started. This can be used for one-time tasks, like those that need to be executed only the first time after the installation. Another reason is that a system administrator might want to disable an unused service or one that is being tested.

Show masked units

To show the masked units, we can ask systemctl to show all unit files with a state of masked.

systemctl list-unit-files --state=masked

When there are matches, the output could look like this:

# systemctl list-unit-files --state=masked
UNIT FILE                STATE  PRESET 
cryptdisks-early.service masked enabled
cryptdisks.service       masked enabled
hwclock.service          masked enabled
rc.service               masked enabled
rcS.service              masked enabled
screen-cleanup.service   masked enabled
sudo.service             masked enabled
x11-common.service       masked enabled

8 unit files listed.

Unmask a unit or service

In most cases, a masked unit is a service. Need a particular service to run again? Use the unmask command.

systemctl unmask NAME.service

Learn more about systemctl

This article uses the systemctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: systemctl

systemctl cheat sheet

Other questions related to Systemd

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon