我用来systemctl show --all *
列出所有 systemd 单元和所有实例及其状态。
在某些机器上它可以正常工作。在其他机器上,它仅列出具有LoadError
属性的单元。
一台机器的输出示例:
# systemctl show --no-pager * --property=Id --property=LoadError
Id=int.service
LoadError=org.freedesktop.systemd1.NoSuchUnit "Unit int.service not found."
Id=iptables.txt.service
LoadError=org.freedesktop.systemd1.NoSuchUnit "Unit iptables.txt.service not found."
(只有两个单位返回了“奇怪”的名字,看起来像是打字错误。但systemctl list-units
可以正常工作。)
这是错误还是功能?此行为记录在哪里?如何强制systemctl show
列出所有单元和实例?
您的 shell 正在扩展
*
,因此systemctl
会给出当前目录中文件的列表。你需要逃避它: