首页/系统/Linux 运维命令速查/systemctl list-units 盘点单元清单
systemd 与服务42 条

systemctl list-units 盘点单元清单

查所有已加载单元及其状态:--type=service 聚焦服务、--state=running 只看运行中、--all 含 inactive;巡检与资产盘点基础。

Linux 运维命令速查系统更新于 2026-10-12
用途列出已加载单元与状态
语法systemctl list-units [--type T] [--state S]
所属systemd

常用示例

常用示例
systemctl list-units --type=service --state=running
systemctl list-units --type=service --all | wc -l
systemctl list-units --type=target
systemctl list-unit-files --type=service | grep enabled | head -n 30
list-units 看运行时已加载;list-unit-files 看磁盘上所有单元文件与开机策略,两者口径不同。

易错点

  • list-units 默认未加 --all 时隐藏 inactive 单元,会误以为单元不存在
  • 输出被分页器接管时脚本里加 --no-pager 与 --no-legend 才好解析

数据来源与参考

  • man 1 systemctl(list-units/list-unit-files)

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌