Is there an 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) }'
Is there a clearer way?
To show all installed unit files use 'systemctl list-unit-files'. The header and the last unit of a given type are underlined if the terminal supports that. A colored dot is shown next to services which were masked, not found, or otherwise failed.
This will be displayed if you check e.g. by systemctl status service_name. systemctl list-unit-files is listing the state of the unit files (static, enabled, disabled, masked, indirect) , you can list all services which are masked, enabled or disabled.
To see a list of all of the active units that systemd knows about, we can use the list-units command: systemctl list-units.
Use the systemctl unmask command to unmask the service unit. [root@host ~]# systemctl unmask sendmail Removed /etc/systemd/system/sendmail. service. Note: A disabled service can be started manually or by other unit files but it does not start automatically at boot.
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}'
The --state
option would do the job
systemctl list-unit-files --state=masked
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With