如何列出所有 systemd 掩码单元?
How do I list all systemd masked units?
是否有一种简单的方法来列出所有 systemd 屏蔽单元?
我能想到:
ls -l /etc/systemd/system/* | grep /dev/null
或(仅限单位名称):
ls -l /etc/systemd/system/* | grep /dev/null | cut -d' ' -f12 | awk -F'/' '{ print $(NF) }'
有没有更清晰的方法?
我认为获取此信息的最佳方式可能是:
systemctl list-unit-files | grep masked
或者,对于单位名称:
systemctl list-unit-files | awk '/masked/ {print }'
当然,这些表达式中的任何一个实际上都匹配名称中包含 "masked" 的单元。更准确的是:
systemctl list-unit-files | awk ' == "masked" {print }'
--state
选项就可以了
systemctl list-unit-files --state=masked
是否有一种简单的方法来列出所有 systemd 屏蔽单元?
我能想到:
ls -l /etc/systemd/system/* | grep /dev/null
或(仅限单位名称):
ls -l /etc/systemd/system/* | grep /dev/null | cut -d' ' -f12 | awk -F'/' '{ print $(NF) }'
有没有更清晰的方法?
我认为获取此信息的最佳方式可能是:
systemctl list-unit-files | grep masked
或者,对于单位名称:
systemctl list-unit-files | awk '/masked/ {print }'
当然,这些表达式中的任何一个实际上都匹配名称中包含 "masked" 的单元。更准确的是:
systemctl list-unit-files | awk ' == "masked" {print }'
--state
选项就可以了
systemctl list-unit-files --state=masked