systemctl 命令完全指南(二)

2016-12-17 18:01:52 6522


7. 列出所有可用单元

# systemctl list-unit-files
UNIT FILE STATE
proc-sys-fs-binfmt_misc.automount static
dev-hugepages.mount static
dev-mqueue.mount static
proc-sys-fs-binfmt_misc.mount static
sys-fs-fuse-connections.mount static
sys-kernel-config.mount static
sys-kernel-debug.mount static
tmp.mount disabled
brandbot.path disabled
.....

8. 列出所有运行中单元

# systemctl list-units
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting ArbitraryExecutableFileFormatsFileSyste
sys-devices-pc...0-1:0:0:0-block-sr0.device loaded active plugged VBOX_CD-ROM
sys-devices-pc...:00:03.0-net-enp0s3.device loaded active plugged PRO/1000 MT DesktopAdapter
sys-devices-pc...00:05.0-sound-card0.device loaded active plugged 82801AA AC'97 Audio Controller
sys-devices-pc...:0:0-block-sda-sda1.device loaded active plugged VBOX_HARDDISK
sys-devices-pc...:0:0-block-sda-sda2.device loaded active plugged LVM PV Qzyo3l-qYaL-uRUa-Cjuk-pljo-qKtX-VgBQ8
sys-devices-pc...0-2:0:0:0-block-sda.device loaded active plugged VBOX_HARDDISK
sys-devices-pl...erial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS0
sys-devices-pl...erial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS1
sys-devices-pl...erial8250-tty-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2
sys-devices-pl...erial8250-tty-ttyS3.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS3
sys-devices-virtual-block-dmx2d0.device loaded active plugged /sys/devices/virtual/block/dm-0
sys-devices-virtual-block-dmx2d1.device loaded active plugged /sys/devices/virtual/block/dm-1
sys-module-configfs.device loaded active plugged /sys/module/configfs
...

9. 列出所有失败单元

# systemctl --failed
UNIT LOAD ACTIVE SUB DESCRIPTION
kdump.service loaded failed failed Crash recovery kernel arming
LOAD =Reflects whether the unit definition was properly loaded.
ACTIVE =The high-level unit activation state, i.e. generalization of SUB.
SUB =The low-level unit activation state, values depend on unit type.
1 loaded units listed.Pass--all to see loaded but inactive units, too.
To show all installed unit files use'systemctl list-unit-files'.

10. 检查某个单元(如 cron.service)是否启用

# systemctl is-enabled crond.service
enabled

11. 检查某个单元或服务是否运行

# systemctl status firewalld.service
firewalld.service - firewalld -dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)
Active: active (running) since Tue2015-04-2816:27:55 IST;34min ago
Main PID:549(firewalld)
CGroup:/system.slice/firewalld.service
└─549/usr/bin/python -Es/usr/sbin/firewalld --nofork --nopid
Apr2816:27:51 tecmint systemd[1]:Starting firewalld -dynamic firewall daemon...
Apr2816:27:55 tecmint systemd[1]:Started firewalld -dynamic firewall daemon.

提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: