在 Linux 系统中,systemd 是一种系统和服务管理器(System and Service Manager),它是现代大多数 Linux 发行版(如 Fedora、Ubuntu、CentOS 等)默认使用的初始化系统(init system)。它取代了传统的 SysV init 和 Upstart,旨在提高系统启动速度、管理服务的依赖关系,并提供更强大的功能。
[root@backup ~]# systemctl list-units --type=service UNIT LOAD ACTIVE SUB DESCRIPTION abrt-ccpp.service loaded active exited Install ABRT coredump hook abrt-oops.service loaded active running ABRT kernel log watcher abrt-xorg.service loaded active running ABRT Xorg log watcher abrtd.service loaded active running ABRT Automated Bug Reporting Tool accounts-daemon.service loaded active running Accounts Service alsa-state.service loaded active running Manage Sound Card State (restore and store) atd.service loaded active running Job spooling tools auditd.service loaded active running Security Auditing Service avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack blk-availability.service loaded active exited Availability of block devices bolt.service loaded active running Thunderbolt system service chronyd.service loaded active running NTP client/server colord.service loaded active running Manage, Install and Generate Color Profiles containerd.service loaded active running containerd container runtime crond.service loaded active running Command Scheduler cups.service loaded active running CUPS Printing Service dbus.service loaded active running D-Bus System Message Bus gdm.service loaded active running GNOME Display Manager gssproxy.service loaded active running GSSAPI Proxy Daemon irqbalance.service loaded active running irqbalance daemon iscsi-shutdown.service loaded active exited Logout off all iSCSI sessions on shutdown kdump.service loaded active exited Crash recovery kernel arming kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel ksm.service loaded active exited Kernel Samepage Merging ……
[root@backup ~]# systemctl list-units --type=service --state=running UNIT LOAD ACTIVE SUB DESCRIPTION abrt-oops.service loaded active running ABRT kernel log watcher abrt-xorg.service loaded active running ABRT Xorg log watcher abrtd.service loaded active running ABRT Automated Bug Reporting Tool accounts-daemon.service loaded active running Accounts Service alsa-state.service loaded active running Manage Sound Card State (restore and store) atd.service loaded active running Job spooling tools auditd.service loaded active running Security Auditing Service avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack bolt.service loaded active running Thunderbolt system service chronyd.service loaded active running NTP client/server colord.service loaded active running Manage, Install and Generate Color Profiles ……
[root@backup ~]# systemctl list-units --all --type=service UNIT LOAD ACTIVE SUB DESCRIPTION abrt-ccpp.service loaded active exited Install ABRT coredump hook abrt-oops.service loaded active running ABRT kernel log watcher abrt-vmcore.service loaded inactive dead Harvest vmcores for ABRT abrt-xorg.service loaded active running ABRT Xorg log watcher abrtd.service loaded active running ABRT Automated Bug Reporting Tool accounts-daemon.service loaded active running Accounts Service alsa-restore.service loaded inactive dead Save/Restore Sound Card State alsa-state.service loaded active running Manage Sound Card State (restore and store) ● apparmor.service not-found inactive dead apparmor.service atd.service loaded active running Job spooling tools auditd.service loaded active running Security Auditing Service auth-rpcgss-module.service loaded inactive dead Kernel Module supporting RPCSEC_GSS avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack blk-availability.service loaded active exited Availability of block devices bolt.service loaded active running Thunderbolt system service chronyd.service loaded active running NTP client/server ● cloud-init-local.service not-found inactive dead cloud-init-local.service colord.service loaded active running Manage, Install and Generate Color Profiles ……
5.列出所有非活动 systemd 服务
如果只想查看所有非活动服务,可以在–state=inactive参数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
systemctl list-units --all --type=service --state=inactive [root@backup ~]# systemctl list-units --all --type=service --state=inactive UNIT LOAD ACTIVE SUB DESCRIPTION abrt-vmcore.service loaded inactive dead Harvest vmcores for ABRT alsa-restore.service loaded inactive dead Save/Restore Sound Card State ● apparmor.service not-found inactive dead apparmor.service auth-rpcgss-module.service loaded inactive dead Kernel Module supporting RPCSEC_GSS ● cloud-init-local.service not-found inactive dead cloud-init-local.service cpupower.service loaded inactive dead Configure CPU power related settings dm-event.service loaded inactive dead Device-mapper event daemon dmraid-activation.service loaded inactive dead Activation of DM RAID sets dracut-cmdline.service loaded inactive dead dracut cmdline hook dracut-initqueue.service loaded inactive dead dracut initqueue hook dracut-mount.service loaded inactive dead dracut mount hook ……