Ilias95 Ilias95 - 1 year ago 83
Linux Question

systemd - how to list all masked units

Is there any easy way to list all systemd masked units?

I can think of:

ls -l /etc/systemd/system/* | grep /dev/null

or (for unit names only):

ls -l /etc/systemd/system/* | grep /dev/null | cut -d' ' -f12 | awk -F'/' '{ print $(NF) }'

Any clearer way?

Answer Source

I think the best way of getting this information might be:

systemctl list-unit-files | grep masked

Or, for just unit names:

systemctl list-unit-files | awk '/masked/ {print $1}'

Of course, either of those expressions would actually match units that contained "masked" in the name. More accurate would be:

systemctl list-unit-files | awk '$2 == "masked" {print $1}'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download