简体   繁体   English

如何列出所有系统蒙版单元?

[英]How do I list all systemd masked units?

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? 有更清晰的方法吗?

--state选项可以完成这项工作

systemctl list-unit-files --state=masked

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. 当然,这些表达式中的任何一个实际上都匹配名称中包含“masked”的单元。 More accurate would be: 更准确的是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM