事实上,systemd 不仅仅是一个程序。它是一套大型程序,所有这些程序都旨在协同工作以管理正在运行的 Linux 系统的几乎所有方面。对 systemd 的完整阐述本身就需要一本书。我们大多数人不需要了解有关 systemd 的所有组件如何组合在一起的所有细节,因此我将重点介绍使您能够管理各种 Linux 服务以及处理日志文件和日志的程序和组件。
# systemctl --- UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS0 sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS1 sys-devices-platform-serial8250-tty-ttyS10.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS10 sys-devices-platform-serial8250-tty-ttyS11.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS11 sys-devices-platform-serial8250-tty-ttyS12.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS12 sys-devices-virtual-misc-rfkill.device loaded active plugged /sys/devices/virtual/misc/rfkill sys-module-configfs.device loaded active plugged /sys/module/configfs sys-module-fuse.device loaded active plugged /sys/module/fuse sys-subsystem-net-devices-enp0s3.device loaded active plugged 82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapter) sys-subsystem-net-devices-enp0s8.device loaded active plugged 82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapter) -.mount loaded active mounted Root Mount dev-hugepages.mount loaded active mounted Huge Pages File System dev-mqueue.mount loaded active mounted POSIX Message Queue File System run-credentials-systemd\x2dsysusers.service.mount loaded active mounted /run/credentials/systemd-sysusers.service run-user-1000.mount loaded active mounted /run/user/1000 srv-share.mount loaded active mounted /srv/share sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System sys-kernel-config.mount loaded active mounted Kernel Configuration File System sys-kernel-debug.mount loaded active mounted Kernel Debug File System sys-kernel-tracing.mount loaded active mounted Kernel Trace File System tmp.mount loaded active mounted Temporary Directory /tmp systemd-ask-password-console.path loaded active waiting Dispatch Password Requests to Console Directory Watch systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch init.scope loaded active running System and Service Manager <snip – removed lots of lines of data from here>
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. 123 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
# systemctl list-timers --- NEXT LEFT LAST PASSED UNIT ACTIVATES Wed 2021-11-10 00:00:00 UTC 14h left Tue 2021-11-09 08:40:46 UTC 1h 8min ago shadow.timer shadow.service Wed 2021-11-10 09:03:15 UTC 23h left Tue 2021-11-09 09:03:15 UTC 46min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
2 timers listed. Pass --all to see loaded but inactive timers, too.
# cat default.target --- # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version.
# systemctl stop pcscd ; systemctl disable pcscd --- Warning: Stopping pcscd.service, but it can still be activated by: pcscd.socket Removed /etc/systemd/system/sockets.target.wants/pcscd.socket.
# systemctl status pcscd --- ● pcscd.service - PC/SC Smart Card Daemon Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2019-05-13 15:23:15 EDT; 48s ago Docs: man:pcscd(8) Main PID: 24706 (code=exited, status=1/FAILURE)
May 10 11:28:42 testvm1 systemd[1]: Started PC/SC Smart Card Daemon. May 13 15:23:15 testvm1 systemd[1]: Stopping PC/SC Smart Card Daemon... May 13 15:23:15 testvm1 systemd[1]: pcscd.service: Main process exited, code=exited, status=1/FAIL> May 13 15:23:15 testvm1 systemd[1]: pcscd.service: Failed with result 'exit-code'. May 13 15:23:15 testvm1 systemd[1]: Stopped PC/SC Smart Card Daemon.
# systemctl status multi-user.target --- ● multi-user.target - Multi-User System Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: disabled) Active: active since Thu 2019-05-09 13:27:22 EDT; 4 days ago Docs: man:systemd.special(7)
May 09 13:27:22 testvm1 systemd[1]: Reached target Multi-User System.
# systemctl status graphical.target --- ● graphical.target - Graphical Interface Loaded: loaded (/usr/lib/systemd/system/graphical.target; indirect; vendor preset: disabled) Active: active since Thu 2019-05-09 13:27:22 EDT; 4 days ago Docs: man:systemd.special(7)
May 09 13:27:22 testvm1 systemd[1]: Reached target Graphical Interface.
# systemctl status default.target --- ● graphical.target - Graphical Interface Loaded: loaded (/usr/lib/systemd/system/graphical.target; indirect; vendor preset: disabled) Active: active since Thu 2019-05-09 13:27:22 EDT; 4 days ago Docs: man:systemd.special(7)
May 09 13:27:22 testvm1 systemd[1]: Reached target Graphical Interface.
# This mount unit is for the TestFS filesystem # By David Both # Licensed under GPL V2 # This file should be located in the /etc/systemd/system directory