How can I list all systemd-masked blocks?

Is there an easy way to list all systemd-masked blocks?

I can think of:

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

Or (only for element names):

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

Is there a clearer way?

+5
source share
2 answers

The --state will do the job

 systemctl list-unit-files --state=masked 
+7
source

I think the best way to get this information is:

 systemctl list-unit-files | grep masked 

Or, for unit names only:

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

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

 systemctl list-unit-files | awk '$2 == "masked" {print $1}' 
+5
source

All Articles