【Linux】2、systemd、journalctl 超详细介绍

文章目录

  • 一、背景
  • 二、系统管理
    • 2.1 systemctl
      • 2.1.1 State: degraded
    • 2.2 systemd-analyze
    • 2.3 hostnamectl
    • 2.4 localectl
    • 2.5 timedatectl
    • 2.6 loginctl
  • 三、Unit
    • 3.1 含义
    • 3.2 展示
    • 3.3 状态
    • 3.4 管理
    • 3.5 依赖关系
  • 四、Unit 的配置文件
    • 4.1 配置文件层级
    • 4.2 配置文件的状态
    • 4.3 配置文件的格式
    • 4.4 配置文件的区块
      • 4.4.1 [Unit]
      • 4.4.2 [Install]
      • 4.4.3 [Service]
  • 五、Target 是 Unit 组
  • 六、journalctl
  • 七、启动
    • 7.1 开机启动
    • 7.2 启停服务

【Linux】2、systemd、journalctl 超详细介绍_第1张图片

官网
systemd 中文手册
System 命令与实战-阮一峰

一、背景

历史上,Linux 的启动一直采用init进程。但有如下两个缺点

  • 启动时间长。init进程是串行启动,只有前一个进程启动完,才会启动下一个进程。
  • 启动脚本复杂。init进程只是执行启动脚本,不管其他事情。脚本需要自己处理各种情况,这往往使得脚本变得很长。
/etc/init.d/apache2 start
service apache2 start

Systemd 就是为了解决这些问题而诞生的。它的设计目标是,为系统的启动和管理提供一套完整的解决方案。

使用了 Systemd,就不需要再用init了。Systemd 取代了initd,成为系统的第一个进程(PID 等于 1),其他进程都是它的子进程。

二、系统管理

2.1 systemctl

systemctl 是 Systemd 的主命令,用于管理系统。

systemctl reboot # 重启
systemctl poweroff # 关闭系统,切断电源
systemctl halt # CPU停止工作
systemctl suspend # 暂停系统
systemctl hibernate # 让系统进入冬眠状态
systemctl hybrid-sleep # 让系统进入交互式休眠状态
systemctl rescue # 启动进入救援状态(单用户状态)

2.1.1 State: degraded

当 systemctl status 命令输出 State: degraded 时,意味着有些服务无法启动

  • 可通过 systemctl 查看所有服务
  • 可通过 systemctl --failedsystemctl | grep fail 查看所有失败的服务

2.2 systemd-analyze

查看启动耗时

# 查看启动耗时
root@node:~# systemd-analyze
Startup finished in 8.149s (kernel) + 10.497s (userspace) = 18.646s
graphical.target reached after 10.416s in userspace
                                  
# 查看每个服务的启动耗时                                          
root@node:~# systemd-analyze blame
1.306s app-docker.service
1.008s dev-loop1.device
 920ms systemd-timesyncd.service

# 显示瀑布状的启动过程流
root@node:~# systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.
graphical.target @10.416s
└─multi-user.target @10.416s
  └─entry-app.service @4.001s +6.413s
    └─entry-sys.service @2.651s +1.330s
      └─basic.target @2.614s
        └─sockets.target @2.598s
          └─app-docker.socket @6.073s +77ms
            └─sysinit.target @2.488s
              └─systemd-timesyncd.service @5.070s +920ms
                └─systemd-tmpfiles-setup.service @1.916s +28ms
                  └─systemd-journal-flush.service @1.336s +463ms
                    └─systemd-remount-fs.service @936ms +347ms
                      └─systemd-journald.socket @578ms
                        └─system.slice @268ms
                          └─-.slice @268ms

# 显示指定服务的启动流
root@node:~# systemd-analyze critical-chain app-docker.socket
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.
app-docker.socket +77ms
└─sysinit.target @2.488s
  └─systemd-timesyncd.service @5.070s +920ms
    └─systemd-tmpfiles-setup.service @1.916s +28ms
      └─systemd-journal-flush.service @1.336s +463ms
        └─systemd-remount-fs.service @936ms +347ms
          └─systemd-journald.socket @578ms
            └─system.slice @268ms
              └─-.slice @268ms

2.3 hostnamectl

查看当前主机的信息

root@node:~# hostnamectl -h
hostnamectl [OPTIONS...] COMMAND ...

Query or change system hostname.

Commands:
  status                 Show current hostname settings
  set-hostname NAME      Set system hostname
  set-icon-name NAME     Set icon name for host
  set-chassis NAME       Set chassis type for host
  set-deployment NAME    Set deployment environment for host
  set-location NAME      Set location for host

Options:
  -h --help              Show this help
     --version           Show package version
     --no-ask-password   Do not prompt for password
  -H --host=[USER@]HOST  Operate on remote host
  -M --machine=CONTAINER Operate on local container
     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname

See the hostnamectl(1) man page for details.

root@node:~# hostnamectl status
   Static hostname: node
         Icon name: computer
        Machine ID: xxx
           Boot ID: yyy
  Operating System: Ubuntu 20.04.4 LTS
            Kernel: Linux 4.30
      Architecture: arm64

hostnamectl # 显示当前主机的信息
hostnamectl set-hostname rhel7 # 设置主机名。

2.4 localectl

查看本地化设置

# 查看本地化设置
root@node:~# localectl
   System Locale: LANG=C
                  LC_CTYPE=C.UTF-8
                  LC_NUMERIC=C.UTF-8
                  LC_TIME=C.UTF-8
                  LC_COLLATE=C.UTF-8
                  LC_MONETARY=C.UTF-8
                  LC_MESSAGES=C.UTF-8
                  LC_PAPER=C.UTF-8
                  LC_NAME=C.UTF-8
                  LC_ADDRESS=C.UTF-8
                  LC_TELEPHONE=C.UTF-8
                  LC_MEASUREMENT=C.UTF-8
                  LC_IDENTIFICATION=C.UTF-8
       VC Keymap: n/a
      X11 Layout: n/a

# 设置本地化参数
localectl set-locale LANG=en_GB.utf8
localectl set-keymap en_GB

2.5 timedatectl

查看当前时区

# 查看当前时区设置
root@node:~# timedatectl
               Local time: Sat 2023-04-22 23:26:11 CST
           Universal time: Sat 2023-04-22 15:26:11 UTC
                 RTC time: Sat 2023-04-22 15:26:12
                Time zone: localtime (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

# 显示所有可用的时区
root@node:~# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers                                                                                 

# 设置当前时区
sudo timedatectl set-timezone America/New_York
sudo timedatectl set-time YYYY-MM-DD
sudo timedatectl set-time HH:MM:SS

2.6 loginctl

查看当前登录的用户


# 列出当前session
root@node:~# loginctl list-sessions
No sessions.

# 列出当前登录用户
root@node:~# loginctl list-users
No users.

# 列出显示指定用户的信息
root@node:~# loginctl show-user userabc
Failed to look up user userabc: No such process

三、Unit

3.1 含义

Systemd 可以管理所有系统资源。不同的资源统称为 Unit(单位)。Unit 共12种。systemctl list-units 可查当前系统的所有 Unit 。

Service unit:系统服务
Target unit:多个 Unit 构成的一个组
Device Unit:硬件设备
Mount Unit:文件系统的挂载点
Automount Unit:自动挂载点
Path Unit:文件或路径
Scope Unit:不是由 Systemd 启动的外部进程
Slice Unit:进程组
Snapshot Unit:Systemd 快照,可以切回某个快照
Socket Unit:进程间通信的 socket
Swap Unit:swap 文件
Timer Unit:定时器

3.2 展示

root@node:~# systemctl list-units
  UNIT                                                                                 >
  sys-devices-platform-50108000.ethernet-net-eth1.device                               >
  sys-devices-platform-5010c000.ethernet-net-eth0.device                               >
  sys-devices-platform-50118000.serial-tty-ttyS0.device

# 列出所有Unit,包括没有找到配置文件的或者启动失败的
root@node:~# systemctl list-units --all
  UNIT                                                                                 >
  proc-sys-fs-binfmt_misc.automount                                                    >
  dev-disk-by\x2did-ata\x2dWDC_WD20SPZX\x2d00UA7T0_WD\x2dWX92A52DRRNX.device           >
  dev-disk-by\x2did-ata\x2dWDC_WD20SPZX\x2d00UA7T0_WD\x2dWX92A52DRRNX\x2dpart1.device  >
  dev-disk-by\x2did-mmc\x2d88A19B_0x5b97d9a0.device


# 列出所有没有运行的 Unit
root@node:~# systemctl list-units --all --state=inactive
  UNIT                                 LOAD      ACTIVE   SUB  DESCRIPTION                                  >
  proc-sys-fs-binfmt_misc.automount    loaded    inactive dead Arbitrary Executable File Formats File System>
  proc-sys-fs-binfmt_misc.mount        loaded    inactive dead Arbitrary Executable File Formats File System>
  sys-kernel-config.mount              loaded    inactive dead Kernel Configuration File System             >
● auditd.service                       not-found inactive dead auditd.service


# 列出所有加载失败的 Unit
root@node:~# systemctl list-units --failed
  UNIT                    LOAD   ACTIVE SUB    DESCRIPTION
● app-start-freyr.service loaded failed failed run freyr

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.


# 列出所有正在运行的、类型为 service 的 Unit
root@node:~# systemctl list-units --type=service
  UNIT                               LOAD   ACTIVE     SUB          DESCRIPTION                             >
  app-containerd.service             loaded active     running      containerd container runtime            >
  app-deh7.service                   loaded activating auto-restart deh7                                    >
  app-devicefind.service             loaded active     running      DeviceFind                              >
  app-docker.service                 loaded active     running      Docker Application Container Engine


root@node:~/PKG# systemctl list-unit-files
UNIT FILE                              STATE           VENDOR PRESET
proc-sys-fs-binfmt_misc.automount      static          enabled
dev-hugepages.mount                    static          enabled
dev-mqueue.mount                       static          enabled
proc-fs-nfsd.mount                     static          enabled
proc-sys-fs-binfmt_misc.mount          disabled        enabled

3.3 状态

systemctl status命令用于查看系统状态和单个 Unit 的状态。

# 显示系统状态
root@node:~/PKG# systemctl statusnode
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Sat 2023-04-22 18:32:48 CST; 14h ago
   CGroup: /
           ├─init.scope
           │ ├─  1 /lib/systemd/systemd
           │ └─254 haveged -w 1024 -v 1 -F
           └─system.slice
             ├─app-start-pastur.service
             │ ├─701 /bin/sh /home/node/Applications/pastur.app.dpk.mnt/run.sh
             │ └─703 /home/node/Applications/pastur.app.dpk.mnt/pastur -config /home/node/Applications/pastur.app.dpk.mnt/config.toml
             ├─app-deh7.service
             │ └─927 /home/node/Applications/deh7.app.dpk.mnt/deh7
             ├─app-start-aaa.service
             │ ├─834 /bin/sh /home/node/Applications/aaa.app.dpk.mnt/run.sh
             │ └─840 /home/node/Applications/aaa.app.dpk.mnt/aaa
             ├─systemd-timesyncd.service
             │ └─591 /lib/systemd/systemd-timesyncd
# 显示单个 Unit 的状态
root@node:~/PKG# systemctl status app-start-abc.service
● app-start-abc.service - run abc
     Loaded: loaded (/run/systemd/transient/app-start-abc.service; transient)
  Transient: yes
     Active: active (running) since Sat 2023-04-22 18:32:58 CST; 14h ago
   Main PID: 1261 (run.sh)
      Tasks: 12 (limit: 3093)
     Memory: 33.6M
     CGroup: /system.slice/app-start-abc.service
             ├─1261 /bin/sh /home/node/Applications/abc.app.dpk.mnt/run.sh
             └─1263 ./abc

Apr 23 09:07:58 node run.sh[1263]: time="2023-04-23T09:07:58+08:00" level=info msg="vehicle similarity vacuum start at: 2023-04-23 09:07:58.474237963 +0800 CST m=+52500.093>
Apr 23 09:07:58 node run.sh[1263]: time="2023-04-23T09:07:58+08:00" level=info msg="vehicle similarity vacuum end at: 2023-04-23 09:07:58.474237963 +0800 CST m=+52500.09306>
Apr 23 09:08:58 node run.sh[1263]: time="2023-04-23T09:08:58+08:00" level=info msg="vehicle similarity vacuum start at: 2023-04-23 09:08:58.473939125 +0800 CST m=+52560.092>
Apr 23 09:08:58 node run.sh[1263]: time="2023-04-23T09:08:58+08:00" level=info msg="vehicle similarity vacuum end at: 2023-04-23 09:08:58.473939125 +0800 CST m=+52560.09276>
Apr 23 09:09:58 node run.sh[1263]: time="2023-04-23T09:09:58+08:00" level=info msg="vehicle similarity vacuum start at: 2023-04-23 09:09:58.474018147 +0800 CST m=+52620.092>
Apr 23 09:09:58
# 显示远程主机的某个 Unit 的状态
root@node:~/PKG# systemctl -H 192.168.100.31 status  app-start-abc.service
[email protected]'s password:
● app-start-abc.service - run abc
     Loaded: loaded (/run/systemd/transient/app-start-abc.service; transient)
  Transient: yes
     Active: activating (auto-restart) (Result: exit-code) since Sun 2023-04-23 09:15:08 CST; 37ms ago
    Process: 1380597 ExecStart=/home/node/Applications/abc.app.dpk.mnt/run.sh (code=exited, status=2)
   Main PID: 1380597 (code=exited, status=2)

除了status命令,systemctl还提供了三个查询状态的简单方法,主要供脚本内部的判断语句使用。

# 显示某个 Unit 是否正在运行
root@node:~/PKG# systemctl is-active app-start-abc.service
active

# 显示某个 Unit 是否处于启动失败状态
root@node:~/PKG# systemctl is-failed app-start-abc.service
active

# 显示某个 Unit 服务是否建立了启动链接
root@node:~/PKG# systemctl is-enabled app-start-abc.service
transient

3.4 管理

对于用户来说,最常用的是下面这些命令,用于启动和停止 Unit(主要是 service)。

# 显示某个 Unit 的所有底层参数
root@node:~/PKG# systemctl show app-start-abc.service
Restart=no
NotifyAccess=none
RestartUSec=100ms
TimeoutStartUSec=1min 30s
TimeoutStopUSec=30s
TimeoutAbortUSec=30s
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestampMonotonic=0
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=0
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=success
ReloadResult=success
CleanResult=success
UID=[not set]
systemctl restart apache.service # 重启一个服务
systemctl start apache.service # 立即启动一个服务
systemctl stop apache.service # 立即停止一个服务(会导致找不到 unit files,从而无法 systemctl start, 而只能 reboot 才能再拉起服务)
systemctl kill apache.service # 杀死一个服务的所有子进程

root@node:~# systemctl reload app-start-abc.service # 重新加载一个服务的配置文件'
Failed to reload app-start-abc.service: Job type reload is not applicable for unit app-start-abc.service.

systemctl daemon-reload # 重载所有修改过的配置文件

root@node:~# systemctl show -p CPUShares app-start-abc.service # 显示某个 Unit 的指定属性的值
CPUShares=[not set]

root@node:~# systemctl set-property app-start-abc.service CPUShares=500 # 设置某个 Unit 的指定属性
root@node:~# systemctl show -p CPUShares app-start-abc.service
CPUShares=500

3.5 依赖关系

Unit 之间存在依赖关系:A 依赖于 B,就意味着 Systemd 在启动 A 的时候,同时会去启动 B。

# 列出一个 Unit 的所有依赖
root@node:~# systemctl list-dependencies
default.target
● ├─display-manager.service
● ├─systemd-update-utmp-runlevel.service
● └─multi-user.target
●   ├─dbus.service
●   ├─delinux-entry-app.service
●   ├─delinux-entry-sys.service
●   ├─systemd-ask-password-wall.path
●   ├─systemd-networkd.service
●   ├─systemd-resolved.service
●   ├─systemd-update-utmp-runlevel.service
●   ├─systemd-user-sessions.service
●   ├─basic.target
●   │ ├─tmp.mount
●   │ ├─paths.target
●   │ ├─slices.target
●   │ │ ├─-.slice
●   │ │ └─system.slice
●   │ ├─sockets.target
●   │ │ ├─dbus.socket
●   │ │ ├─systemd-initctl.socket
●   │ │ ├─systemd-journald-audit.socket
●   │ │ ├─systemd-journald-dev-log.socket
●   │ │ ├─systemd-journald.socket
●   │ │ ├─systemd-udevd-control.socket
●   │ │ └─systemd-udevd-kernel.socket
●   │ ├─sysinit.target
●   │ │ ├─dev-hugepages.mount
●   │ │ ├─dev-mqueue.mount
●   │ │ ├─kmod-static-nodes.service
●   │ │ ├─proc-sys-fs-binfmt_misc.automount
●   │ │ ├─sys-fs-fuse-connections.mount
●   │ │ ├─sys-kernel-config.mount
●   │ │ ├─sys-kernel-debug.mount
●   │ │ ├─sys-kernel-tracing.mount
●   │ │ ├─systemd-ask-password-console.path
●   │ │ ├─systemd-binfmt.service
●   │ │ ├─systemd-boot-system-token.service
●   │ │ ├─systemd-hwdb-update.service
●   │ │ ├─systemd-journal-flush.service
●   │ │ ├─systemd-journald.service
●   │ │ ├─systemd-machine-id-commit.service
●   │ │ ├─systemd-modules-load.service
●   │ │ ├─systemd-pstore.service
●   │ │ ├─systemd-random-seed.service
●   │ │ ├─systemd-sysctl.service
●   │ │ ├─systemd-sysusers.service
●   │ │ ├─systemd-tmpfiles-setup-dev.service
●   │ │ ├─systemd-tmpfiles-setup.service
●   │ │ ├─systemd-udev-trigger.service
●   │ │ ├─systemd-udevd.service
●   │ │ ├─systemd-update-utmp.service
●   │ │ ├─cryptsetup.target
●   │ │ ├─local-fs.target
●   │ │ │ └─systemd-remount-fs.service
●   │ │ └─swap.target
●   │ └─timers.target
●   │   ├─e2scrub_all.timer
●   │   ├─fstrim.timer
●   │   ├─motd-news.timer
●   │   └─systemd-tmpfiles-clean.timer
●   ├─getty.target
●   │ ├─getty-static.service
●   │ ├─[email protected]
●   │ └─[email protected]
●   ├─nfs-client.target
●   │ ├─nfs-blkmap.service
●   │ ├─rpc-gssd.service
●   │ └─remote-fs-pre.target
●   ├─remote-fs.target
●   │ └─nfs-client.target
●   │   ├─nfs-blkmap.service
●   │   ├─rpc-gssd.service
●   │   └─remote-fs-pre.target
●   └─zfs.target
root@node:~# systemctl list-dependencies app-start-abc.service
app-start-abc.service
● ├─system.slice
● └─sysinit.target
●   ├─dev-hugepages.mount
●   ├─dev-mqueue.mount
●   ├─kmod-static-nodes.service
●   ├─proc-sys-fs-binfmt_misc.automount
●   ├─sys-fs-fuse-connections.mount
●   ├─sys-kernel-config.mount
●   ├─sys-kernel-debug.mount
●   ├─sys-kernel-tracing.mount
●   ├─systemd-ask-password-console.path
●   ├─systemd-binfmt.service
●   ├─systemd-boot-system-token.service
●   ├─systemd-hwdb-update.service
●   ├─systemd-journal-flush.service
●   ├─systemd-journald.service
●   ├─systemd-machine-id-commit.service
●   ├─systemd-modules-load.service
●   ├─systemd-pstore.service
●   ├─systemd-random-seed.service
●   ├─systemd-sysctl.service
●   ├─systemd-sysusers.service
●   ├─systemd-tmpfiles-setup-dev.service
●   ├─systemd-tmpfiles-setup.service
●   ├─systemd-udev-trigger.service
●   ├─systemd-udevd.service
●   ├─systemd-update-utmp.service
●   ├─cryptsetup.target
●   ├─local-fs.target
●   │ └─systemd-remount-fs.service

上面命令的输出结果之中,有些依赖是 Target 类型(详见下文),默认不会展开显示。如果要展开 Target,就需要使用–all参数。

root@node:~# systemctl list-dependencies app-start-abc.service  --all
app-start-abc.service
● ├─system.slice
● │ └─-.slice
● └─sysinit.target
●   ├─dev-hugepages.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─dev-mqueue.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─kmod-static-nodes.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─proc-sys-fs-binfmt_misc.automount
●   ├─sys-fs-fuse-connections.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─sys-kernel-config.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─sys-kernel-debug.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─sys-kernel-tracing.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-ask-password-console.path
●   ├─systemd-binfmt.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-boot-system-token.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-hwdb-update.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-journal-flush.service
●   │ ├─system.slice
●   │ │ └─-.slice
●   │ └─systemd-journald.service
●   │   ├─system.slice
●   │   │ └─-.slice
●   │   ├─systemd-journald-audit.socket
●   │   │ └─system.slice
●   │   │   └─-.slice
●   │   ├─systemd-journald-dev-log.socket
●   │   │ └─system.slice
●   │   │   └─-.slice
●   │   └─systemd-journald.socket
●   │     └─system.slice
●   │       └─-.slice
●   ├─systemd-journald.service
●   │ ├─system.slice
●   │ │ └─-.slice
●   │ ├─systemd-journald-audit.socket
●   │ │ └─system.slice
●   │ │   └─-.slice
●   │ ├─systemd-journald-dev-log.socket
●   │ │ └─system.slice
●   │ │   └─-.slice
●   │ └─systemd-journald.socket
●   │   └─system.slice
●   │     └─-.slice
●   ├─systemd-machine-id-commit.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-modules-load.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-pstore.service
●   │ ├─modprobe@chromeos_pstore.service
●   │ │ └─system-modprobe.slice
●   │ │   └─system.slice
●   │ │     └─-.slice
●   │ ├─modprobe@efi_pstore.service
●   │ │ └─system-modprobe.slice
●   │ │   └─system.slice
●   │ │     └─-.slice
●   │ ├─modprobe@pstore_blk.service
●   │ │ └─system-modprobe.slice
●   │ │   └─system.slice
●   │ │     └─-.slice
●   │ ├─modprobe@pstore_zone.service
●   │ │ └─system-modprobe.slice
●   │ │   └─system.slice
●   │ │     └─-.slice
●   │ ├─[email protected]
●   │ │ └─system-modprobe.slice
●   │ │   └─system.slice
●   │ │     └─-.slice
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-random-seed.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-sysctl.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-sysusers.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-tmpfiles-setup-dev.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-tmpfiles-setup.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-udev-trigger.service
●   │ ├─system.slice
●   │ │ └─-.slice
●   │ └─systemd-udevd.service
●   │   ├─system.slice
●   │   │ └─-.slice
●   │   ├─systemd-udevd-control.socket
●   │   │ └─system.slice
●   │   │   └─-.slice
●   │   └─systemd-udevd-kernel.socket
●   │     └─system.slice
●   │       └─-.slice
●   ├─systemd-udevd.service
●   │ ├─system.slice
●   │ │ └─-.slice
●   │ ├─systemd-udevd-control.socket
●   │ │ └─system.slice
●   │ │   └─-.slice
●   │ └─systemd-udevd-kernel.socket
●   │   └─system.slice
●   │     └─-.slice
●   ├─systemd-update-utmp.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─cryptsetup.target
●   ├─local-fs.target
●   │ └─systemd-remount-fs.service
●   │   ├─system.slice
●   │   │ └─-.slice
●   │   └─local-fs-pre.target
●   └─swap.target

四、Unit 的配置文件

每一个 Unit 都有一个配置文件,告诉 Systemd 怎么启动这个 Unit 。

Systemd

  • 默认从目录 /etc/systemd/system/ 读取配置文件(但里面存放的大部分文件都是符号链接,指向目录 /usr/lib/systemd/system/,真正的配置文件存放在那个目录。)
  • 也可能在/etc/systemd/system目录。
  • 找到配置文件以后,使用文本编辑器打开即可。

systemctl enable 命令用于在上面两个目录之间,建立符号链接关系。如果配置文件里面设置了开机启动则相当于激活开机启动。

systemctl enable [email protected]
# 等同于
ln -s '/usr/lib/systemd/system/[email protected]' '/etc/systemd/system/multi-user.target.wants/[email protected]'
  • systemctl disable 命令用于在两个目录之间,撤销符号链接关系,相当于撤销开机启动。
systemctl disable [email protected]
  • 配置文件的后缀名,就是该 Unit 的种类,比如 sshd.socket。如果省略,Systemd 默认后缀名为 .service,所以 sshd 会被理解成 sshd.service。

4.1 配置文件层级

root@node:~# ll /etc/systemd/
total 27
drwxr-xr-x 1 root root 4096 Jan  6 14:34 ./
drwxr-xr-x 1 root root 4096 Jan  5 10:38 ../
-rw-r--r-- 1 root root 1029 Feb 20 11:32 journald.conf
-rw-r--r-- 1 root root 1042 Sep  8  2022 logind.conf
lrwxrwxrwx 1 root root   54 Nov 11 16:20 network -> /home/node/SysData/rw_rootfs/etc/systemd/network//
-rw-r--r-- 1 root root  584 Apr  2  2020 networkd.conf
-rw-r--r-- 1 root root  529 Apr  2  2020 pstore.conf
-rw-r--r-- 1 root root  642 Sep  8  2022 resolved.conf
-rw-r--r-- 1 root root  790 Apr  2  2020 sleep.conf
drwxr-xr-x 1 root root 4096 Jan  5 14:38 system/
-rw-r--r-- 1 root root 2180 Jan 31 10:32 system.conf
lrwxrwxrwx 1 root root   60 Nov 11 16:20 timesyncd.conf -> /home/node/SysData/rw_rootfs/etc/systemd/timesyncd.conf
drwxr-xr-x 2 root root    3 Sep  8  2022 user/
-rw-r--r-- 1 root root 1185 Sep  8  2022 user.conf
root@node:~# ll /etc/systemd/system
total 43
drwxr-xr-x 1 root root 4096 Jan  5 14:38  ./
drwxr-xr-x 1 root root 4096 Jan  6 14:34  ../
lrwxrwxrwx 1 root root    9 Nov 11 16:20  apt-daily-upgrade.timer -> /dev/null
lrwxrwxrwx 1 root root    9 Nov 11 16:20  apt-daily.timer -> /dev/null
lrwxrwxrwx 1 root root   44 Nov 24 10:47  dbus-org.freedesktop.resolve1.service -> /lib/systemd/system/systemd-resolved.service
lrwxrwxrwx 1 root root   45 Nov 24 10:47  dbus-org.freedesktop.timesync1.service -> /lib/systemd/system/systemd-timesyncd.service
drwxr-xr-x 2 root root   43 Nov 11 16:20  default.target.wants/
-rw-r--r-- 1 root root  279 Nov 11 16:20  delinux-entry-app.service
-rw-r--r-- 1 root root  241 Nov 11 16:20  delinux-entry-sys.service
-rw-r--r-- 1 root root 1486 Nov 11 16:20 '[email protected]'
-rw-r--r-- 1 root root  492 Nov 11 16:20 '[email protected]'
-rw-r--r-- 1 root root  279 Jan  5 11:13  freyr.service
drwxr-xr-x 2 root root   41 Nov 24 10:47  getty.target.wants/
drwxr-xr-x 2 root root  394 Nov 11 16:20  multi-user.target.wants/
-rw-r--r-- 1 root root  274 Jan  5 11:03  nginx.service
-rw-r--r-- 1 root root  283 Jan  5 11:07  abc.service
-rw-r--r-- 1 root root  274 Jan  5 11:09  redis.service
drwxr-xr-x 2 root root   40 Nov 24 10:51  remote-fs.target.wants/
lrwxrwxrwx 1 root root    9 Nov 11 16:20 '[email protected]' -> /dev/null
lrwxrwxrwx 1 root root   41 Nov 24 10:57  smartd.service -> /lib/systemd/system/smartmontools.service
drwxr-xr-x 2 root root   37 Nov 11 16:20  sockets.target.wants/
lrwxrwxrwx 1 root root    9 Nov 11 16:20  sshd.service -> /dev/null
drwxr-xr-x 2 root root   78 Nov 11 16:20  sysinit.target.wants/
drwxr-xr-x 2 root root  137 Nov 11 16:20  timers.target.wants/
-rw-r--r-- 1 root root  279 Jan  5 14:37  aaa.service
-rw-r--r-- 1 root root  279 Jan  5 14:39  bbb.service
-rw-r--r-- 1 root root  297 Jan  5 11:15  weedfs_master.service
-rw-r--r-- 1 root root  297 Jan  5 11:16  weedfs_volume.service
drwxr-xr-x 2 root root   47 Nov 11 16:20  zfs-import.target.wants/
drwxr-xr-x 2 root root   46 Nov 11 16:20  zfs-mount.service.wants/
drwxr-xr-x 2 root root   46 Nov 11 16:20  zfs-volumes.target.wants/
drwxr-xr-x 2 root root  147 Nov 11 16:20  zfs.target.wants/
root@node:~# cat /etc/systemd/journald.conf
# See journald.conf(5) for details.
[Journal]
Storage=persistent
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
RateLimitIntervalSec=0
RateLimitBurst=0
SystemMaxUse=1024M
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=yes
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
root@node:~# cat /etc/systemd/system.conf
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See systemd-system.conf(5) for details.

[Manager]
#LogLevel=info
#LogTarget=journal-or-kmsg
#LogColor=yes
#LogLocation=no
#DumpCore=yes
#ShowStatus=yes
#CrashChangeVT=no
#CrashShell=no
#CrashReboot=no
#CtrlAltDelBurstAction=reboot-force
#CPUAffinity=1 2
#NUMAPolicy=default
#NUMAMask=
#RuntimeWatchdogSec=0
#RebootWatchdogSec=10min
#ShutdownWatchdogSec=10min
#KExecWatchdogSec=0
#WatchdogDevice=
#CapabilityBoundingSet=
#NoNewPrivileges=no
#SystemCallArchitectures=
#TimerSlackNSec=
#StatusUnitFormat=description
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=journal
#DefaultStandardError=inherit
#DefaultTimeoutStartSec=90s
DefaultTimeoutStopSec=30s
#DefaultTimeoutAbortSec=
#DefaultRestartSec=100ms
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5
DefaultEnvironment=LANG=C LANGUAGE=C LC_ADDRESS=C.UTF-8 LC_ALL=C.UTF-8 LC_COLLATE=C.UTF-8 LC_CTYPE=C.UTF-8 LC_IDENTIFICATION=C.UTF-8 LC_MEASUREMENT=C.UTF-8 LC_MESSAGES=C.UTF-8 LC_MONETARY=C.UTF-8 LC_NAME=C.UTF-8 LC_NUMERIC=C.UTF-8 LC_PAPER=C.UTF-8 LC_TELEPHONE=C.UTF-8 LC_TIME=C.UTF-8 PATH=/home/node/Applications/docker.app.dpk.mnt/usr/bin:/home/node/Applications/desys.sys.dpk.mnt/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#DefaultCPUAccounting=no
#DefaultIOAccounting=no
#DefaultIPAccounting=no
#DefaultBlockIOAccounting=no
#DefaultMemoryAccounting=yes
#DefaultTasksAccounting=yes
#DefaultTasksMax=
#DefaultLimitCPU=
#DefaultLimitFSIZE=
#DefaultLimitDATA=
#DefaultLimitSTACK=
#DefaultLimitCORE=
#DefaultLimitRSS=
DefaultLimitNOFILE=10240:5242880
#DefaultLimitAS=
#DefaultLimitNPROC=
#DefaultLimitMEMLOCK=
#DefaultLimitLOCKS=
#DefaultLimitSIGPENDING=
#DefaultLimitMSGQUEUE=
#DefaultLimitNICE=
#DefaultLimitRTPRIO=
#DefaultLimitRTTIME=
root@node:~# cat /etc/systemd/user.conf
# You can override the directives in this file by creating files in
# /etc/systemd/user.conf.d/*.conf.
#
# See systemd-user.conf(5) for details

[Manager]
#LogLevel=info
#LogTarget=console
#LogColor=yes
#LogLocation=no
#SystemCallArchitectures=
#TimerSlackNSec=
#StatusUnitFormat=description
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=inherit
#DefaultStandardError=inherit
#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
#DefaultTimeoutAbortSec=
#DefaultRestartSec=100ms
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5
#DefaultEnvironment=
#DefaultLimitCPU=
#DefaultLimitFSIZE=
#DefaultLimitDATA=
#DefaultLimitSTACK=
#DefaultLimitCORE=
#DefaultLimitRSS=
#DefaultLimitNOFILE=
#DefaultLimitAS=
#DefaultLimitNPROC=
#DefaultLimitMEMLOCK=
#DefaultLimitLOCKS=
#DefaultLimitSIGPENDING=
#DefaultLimitMSGQUEUE=
#DefaultLimitNICE=
#DefaultLimitRTPRIO=
#DefaultLimitRTTIME=
root@node:/etc/systemd# ll 
lrwxrwxrwx 1 root root   60 Nov 11 16:20 timesyncd.conf -> /home/node/SysData/rw_rootfs/etc/systemd/timesyncd.conf

root@node:/etc/systemd# cat timesyncd.conf
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See timesyncd.conf(5) for details.

[Time]
NTP=192.168.2.165
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
root@node:/etc/systemd# ll | grep network
lrwxrwxrwx 1 root root   54 Nov 11 16:20 network -> /home/node/SysData/rw_rootfs/etc/systemd/network//
-rw-r--r-- 1 root root  584 Apr  2  2020 networkd.conf



root@node:/etc/systemd# cat network/eth0.network
[Match]
Name=eth0
[Network]
Address=192.168.100.130/23
[Route]
Gateway=192.168.101.254

root@node:/etc/systemd# cat network/eth1.network
[Match]
Name=eth1
[Network]
Address=192.168.13.188/24
[Route]
Gateway=192.168.13.254



root@node:/etc/systemd# cat networkd.conf/
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See networkd.conf(5) for details

[Network]
#SpeedMeter=no
#SpeedMeterIntervalSec=10sec

[DHCP]
#DUIDType=vendor
#DUIDRawData=
root@node:/etc/systemd/system# ll
total 43
drwxr-xr-x 1 root root 4096 Jan  5 14:38  ./
drwxr-xr-x 1 root root 4096 Jan  6 14:34  ../
lrwxrwxrwx 1 root root    9 Nov 11 16:20  apt-daily-upgrade.timer -> /dev/null
lrwxrwxrwx 1 root root    9 Nov 11 16:20  apt-daily.timer -> /dev/null
lrwxrwxrwx 1 root root   44 Nov 24 10:47  dbus-org.freedesktop..service -> /lib/systemd/system/systemd-resolved.service
lrwxrwxrwx 1 root root   45 Nov 24 10:47  dbus-org.freedesktop.timesync1.service -> /lib/systemd/system/systemd-timesyncd.service
drwxr-xr-x 2 root root   43 Nov 11 16:20  default.target.wants/
-rw-r--r-- 1 root root  279 Nov 11 16:20  delinux-entry-app.service
-rw-r--r-- 1 root root  241 Nov 11 16:20  delinux-entry-sys.service
-rw-r--r-- 1 root root 1486 Nov 11 16:20 '[email protected]'
-rw-r--r-- 1 root root  492 Nov 11 16:20 '[email protected]'
-rw-r--r-- 1 root root  279 Jan  5 11:13  freyr.service
drwxr-xr-x 2 root root   41 Nov 24 10:47  getty.target.wants/
drwxr-xr-x 2 root root  394 Nov 11 16:20  multi-user.target.wants/
-rw-r--r-- 1 root root  274 Jan  5 11:03  nginx.service
-rw-r--r-- 1 root root  283 Jan  5 11:07  abc.service
-rw-r--r-- 1 root root  274 Jan  5 11:09  redis.service
drwxr-xr-x 2 root root   40 Nov 24 10:51  remote-fs.target.wants/
lrwxrwxrwx 1 root root    9 Nov 11 16:20 '[email protected]' -> /dev/null
lrwxrwxrwx 1 root root   41 Nov 24 10:57  smartd.service -> /lib/systemd/system/smartmontools.service
drwxr-xr-x 2 root root   37 Nov 11 16:20  sockets.target.wants/
lrwxrwxrwx 1 root root    9 Nov 11 16:20  sshd.service -> /dev/null
drwxr-xr-x 2 root root   78 Nov 11 16:20  sysinit.target.wants/
drwxr-xr-x 2 root root  137 Nov 11 16:20  timers.target.wants/
-rw-r--r-- 1 root root  279 Jan  5 14:37  aaa.service
-rw-r--r-- 1 root root  279 Jan  5 14:39  bbb.service
-rw-r--r-- 1 root root  297 Jan  5 11:15  weedfs_master.service
-rw-r--r-- 1 root root  297 Jan  5 11:16  weedfs_volume.service
drwxr-xr-x 2 root root   47 Nov 11 16:20  zfs-import.target.wants/
drwxr-xr-x 2 root root   46 Nov 11 16:20  zfs-mount.service.wants/
drwxr-xr-x 2 root root   46 Nov 11 16:20  zfs-volumes.target.wants/
drwxr-xr-x 2 root root  147 Nov 11 16:20  zfs.target.wants/



root@node:/etc/systemd/system# cat sshd.service
root@node:/etc/systemd/system# cat abc.service
[Unit]
Description=This is abc  service

[Service]
User=root
LimitNOFILE=65535
ExecStart=/bin/bash -c "cd /home/node/Applications/abc/abc/latest/ && ./run.sh"
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target




root@node:/etc/systemd/system# cat redis.service
[Unit]
Description=This is redis  service

[Service]
User=root
LimitNOFILE=65535
ExecStart=/bin/bash -c "cd /home/node/Applications/REDIS/latest/ && ./run.sh"
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target




root@node:/etc/systemd/system# cat nginx.service
[Unit]
Description=This is nginx  service

[Service]
User=root
LimitNOFILE=65535
ExecStart=/bin/bash -c "cd /home/node/Applications/NGINX/latest/ && ./run.sh"
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target



root@node:/etc/systemd/system# cat aaa.service
[Unit]
Description=This is aaa service

[Service]
User=root
LimitNOFILE=65535
ExecStart=/bin/bash -c "cd /home/node/Applications/aaa/aaa/latest/ && ./run.sh"
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target



root@node:/etc/systemd/system# cat bbb.service
[Unit]
Description=This is bbb service

[Service]
User=root
LimitNOFILE=65535
ExecStart=/bin/bash -c "cd /home/node/Applications/bbb/bbb/latest/ && ./run.sh"
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target



root@node:/etc/systemd/system# cat weedfs_master.service
[Unit]
Description=This is weedfs_master  service

[Service]
User=root
LimitNOFILE=65535
ExecStart=/bin/bash -c "cd  /home/node/Applications/WEEDFS/weedfs/latest && ./run_server.sh"
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target



root@node:/etc/systemd/system# cat weedfs_volume.service
[Unit]
Description=This is weedfs_volume  service

[Service]
User=root
LimitNOFILE=65535
ExecStart=/bin/bash -c "cd  /home/node/Applications/WEEDFS/weedfs/latest && ./run_volume.sh"
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target
root@node:/etc/systemd/system/multi-user.target.wants# ll
total 4
drwxr-xr-x 2 root root  394 Nov 11 16:20 ./
drwxr-xr-x 1 root root 4096 Jan  5 14:38 ../
lrwxrwxrwx 1 root root    9 Nov 11 16:20 auditd.service -> /dev/null
lrwxrwxrwx 1 root root   45 Nov 11 16:20 delinux-entry-app.service -> /etc/systemd/system/delinux-entry-app.service
lrwxrwxrwx 1 root root   45 Nov 11 16:20 delinux-entry-sys.service -> /etc/systemd/system/delinux-entry-sys.service
lrwxrwxrwx 1 root root    9 Nov 11 16:20 networkd-dispatcher.service -> /dev/null
lrwxrwxrwx 1 root root   37 Nov 24 10:51 nfs-client.target -> /lib/systemd/system/nfs-client.target
lrwxrwxrwx 1 root root    9 Nov 11 16:20 ondemand.service -> /dev/null
lrwxrwxrwx 1 root root   36 Nov 24 10:47 remote-fs.target -> /lib/systemd/system/remote-fs.target
lrwxrwxrwx 1 root root    9 Nov 11 16:20 rpcbind.service -> /dev/null
lrwxrwxrwx 1 root root    9 Nov 11 16:20 smartmontools.service -> /dev/null
lrwxrwxrwx 1 root root    9 Nov 11 16:20 ssh.service -> /dev/null
lrwxrwxrwx 1 root root    9 Nov 11 16:20 systemd-logind.service -> /dev/null
lrwxrwxrwx 1 root root   44 Nov 11 16:20 systemd-networkd.service -> /lib/systemd/system/systemd-networkd.service
lrwxrwxrwx 1 root root   44 Nov 24 10:47 systemd-resolved.service -> /lib/systemd/system/systemd-resolved.service
lrwxrwxrwx 1 root root   30 Nov 24 18:52 zfs.target -> /lib/systemd/system/zfs.target
root@node:/etc/systemd/system# ll default.target.wants/
total 4
drwxr-xr-x 2 root root   43 Nov 11 16:20 ./
drwxr-xr-x 1 root root 4096 Jan  5 14:38 ../
lrwxrwxrwx 1 root root    9 Nov 11 16:20 e2scrub_reap.service -> /dev/null
root@node:/etc/systemd/system# ll getty.target.wants/
total 4
drwxr-xr-x 2 root root   41 Nov 24 10:47  ./
drwxr-xr-x 1 root root 4096 Jan  5 14:38  ../
lrwxrwxrwx 1 root root   34 Nov 24 10:47 '[email protected]' -> '/lib/systemd/system/[email protected]'
root@node:/etc/systemd/system# ll sysinit.target.wants/
total 4
drwxr-xr-x 2 root root   78 Nov 11 16:20 ./
drwxr-xr-x 1 root root 4096 Jan  5 14:38 ../
lrwxrwxrwx 1 root root   42 Nov 24 10:47 systemd-pstore.service -> /lib/systemd/system/systemd-pstore.service
lrwxrwxrwx 1 root root    9 Nov 11 16:20 systemd-timesyncd.service -> /dev/null
root@node:/etc/systemd/system# ll sockets.target.wants/
total 4
drwxr-xr-x 2 root root   37 Nov 11 16:20 ./
drwxr-xr-x 1 root root 4096 Jan  5 14:38 ../
lrwxrwxrwx 1 root root    9 Nov 11 16:20 rpcbind.socket -> /dev/null
root@node:/etc/systemd/system# ll timers.target.wants/
total 4
drwxr-xr-x 2 root root  137 Nov 11 16:20 ./
drwxr-xr-x 1 root root 4096 Jan  5 14:38 ../
lrwxrwxrwx 1 root root    9 Nov 11 16:20 apt-daily-upgrade.timer -> /dev/null
lrwxrwxrwx 1 root root    9 Nov 11 16:20 apt-daily.timer -> /dev/null
lrwxrwxrwx 1 root root   37 Feb 22  2022 e2scrub_all.timer -> /lib/systemd/system/e2scrub_all.timer
lrwxrwxrwx 1 root root   32 Feb 22  2022 fstrim.timer -> /lib/systemd/system/fstrim.timer
lrwxrwxrwx 1 root root   35 Feb 22  2022 motd-news.timer -> /lib/systemd/system/motd-news.timer
root@node:/usr/lib/systemd# ll
total 8326
drwxr-xr-x 16 root root    1535 Nov 11 16:20 ./
drwxr-xr-x  1 root root    4096 May 31  2022 ../
drwxr-xr-x  3 root root      26 Nov 24 10:47 boot/
drwxr-xr-x  2 root root     339 Nov 24 10:47 catalog/
-rw-r--r--  1 root root 2446488 Sep  8  2022 libsystemd-shared-245.so
drwxr-xr-x  2 root root     266 Nov 24 10:55 network/
drwxr-xr-x  2 root root      47 Nov 24 10:47 ntp-units.d/
-rw-r--r--  1 root root     701 Sep  8  2022 resolv.conf
drwxr-xr-x  2 root root      39 Nov 24 10:51 scripts/
-rwxr-xr-x  1 root root    1246 Sep  8  2022 set-cpufreq*
drwxr-xr-x 18 root root    6894 Nov 11 16:20 system/
drwxr-xr-x  2 root root     452 Nov 24 18:51 system-generators/
drwxr-xr-x  2 root root      61 Nov 24 18:51 system-preset/
drwxr-xr-x  2 root root       3 Sep  8  2022 system-shutdown/
drwxr-xr-x  2 root root       3 Sep  8  2022 system-sleep/
-rwxr-xr-x  1 root root 1551488 Sep  8  2022 systemd*
-rwxr-xr-x  1 root root   10240 Sep  8  2022 systemd-ac-power*
-rwxr-xr-x  1 root root   22520 Sep  8  2022 systemd-backlight*
-rwxr-xr-x  1 root root   14408 Sep  8  2022 systemd-binfmt*
-rwxr-xr-x  1 root root   22632 Sep  8  2022 systemd-bless-boot*
-rwxr-xr-x  1 root root   10240 Sep  8  2022 systemd-boot-check-no-failures*
-rwxr-xr-x  1 root root   10160 Sep  8  2022 systemd-cgroups-agent*
-rwxr-xr-x  1 root root   31024 Sep  8  2022 systemd-cryptsetup*
-rwxr-xr-x  1 root root   14448 Sep  8  2022 systemd-dissect*
-rwxr-xr-x  1 root root   22456 Sep  8  2022 systemd-fsck*
-rwxr-xr-x  1 root root   22528 Sep  8  2022 systemd-fsckd*
-rwxr-xr-x  1 root root   18432 Sep  8  2022 systemd-growfs*
-rwxr-xr-x  1 root root   10160 Sep  8  2022 systemd-hibernate-resume*
-rwxr-xr-x  1 root root   26624 Sep  8  2022 systemd-hostnamed*
-rwxr-xr-x  1 root root   14336 Sep  8  2022 systemd-initctl*
-rwxr-xr-x  1 root root  149552 Sep  8  2022 systemd-journald*
-rwxr-xr-x  1 root root   38912 Sep  8  2022 systemd-localed*
-rwxr-xr-x  1 root root  252112 Sep  8  2022 systemd-logind*
-rwxr-xr-x  1 root root   10160 Sep  8  2022 systemd-makefs*
-rwxr-xr-x  1 root root   14440 Sep  8  2022 systemd-modules-load*
-rwxr-xr-x  1 root root   30720 Sep  8  2022 systemd-network-generator*
-rwxr-xr-x  1 root root 2218920 Sep  8  2022 systemd-networkd*
-rwxr-xr-x  1 root root   26808 Sep  8  2022 systemd-networkd-wait-online*
-rwxr-xr-x  1 root root   18456 Sep  8  2022 systemd-pstore*
-rwxr-xr-x  1 root root   10240 Sep  8  2022 systemd-quotacheck*
-rwxr-xr-x  1 root root   18352 Sep  8  2022 systemd-random-seed*
-rwxr-xr-x  1 root root   18456 Sep  8  2022 systemd-remount-fs*
-rwxr-xr-x  1 root root   10160 Sep  8  2022 systemd-reply-password*
-rwxr-xr-x  1 root root  399472 Sep  8  2022 systemd-resolved*
-rwxr-xr-x  1 root root   18432 Sep  8  2022 systemd-rfkill*
-rwxr-xr-x  1 root root   47168 Sep  8  2022 systemd-shutdown*
-rwxr-xr-x  1 root root   18576 Sep  8  2022 systemd-sleep*
-rwxr-xr-x  1 root root   22528 Sep  8  2022 systemd-socket-proxyd*
-rwxr-xr-x  1 root root   10160 Sep  8  2022 systemd-sulogin-shell*
-rwxr-xr-x  1 root root   18584 Sep  8  2022 systemd-sysctl*
-rwxr-xr-x  1 root root    1360 Jul 20  2022 systemd-sysv-install*
-rwxr-xr-x  1 root root   14256 Sep  8  2022 systemd-time-wait-sync*
-rwxr-xr-x  1 root root   38984 Sep  8  2022 systemd-timedated*
-rwxr-xr-x  1 root root   47104 Sep  8  2022 systemd-timesyncd*
-rwxr-xr-x  1 root root  740368 Sep  8  2022 systemd-udevd*
-rwxr-xr-x  1 root root   14360 Sep  8  2022 systemd-update-utmp*
-rwxr-xr-x  1 root root   14280 Sep  8  2022 systemd-user-runtime-dir*
-rwxr-xr-x  1 root root   10160 Sep  8  2022 systemd-user-sessions*
-rwxr-xr-x  1 root root   14392 Sep  8  2022 systemd-veritysetup*
-rwxr-xr-x  1 root root   14256 Sep  8  2022 systemd-volatile-root*
drwxr-xr-x  3 root root     527 Nov 24 10:52 user/
drwxr-xr-x  2 root root      57 Nov 24 10:47 user-environment-generators/
drwxr-xr-x  2 root root       3 Sep  8  2022 user-generators/
drwxr-xr-x  2 root root      40 Nov 24 10:47 user-preset/
root@node:/usr/lib/systemd/system# ll
total 174
drwxr-xr-x 18 root root 6894 Nov 11 16:20  ./
drwxr-xr-x 16 root root 1535 Nov 11 16:20  ../
-rw-r--r--  1 root root  389 Jun 15  2021  apt-daily-upgrade.service
-rw-r--r--  1 root root  184 Jun 15  2021  apt-daily-upgrade.timer
-rw-r--r--  1 root root  326 Jun 15  2021  apt-daily.service
-rw-r--r--  1 root root  156 Jun 15  2021  apt-daily.timer
-rw-r--r--  1 root root  652 May 25  2021  auth-rpcgss-module.service
lrwxrwxrwx  1 root root   14 Sep  8  2022 '[email protected]' -> '[email protected]'
-rw-r--r--  1 root root  919 Apr  2  2020  basic.target
-rw-r--r--  1 root root  441 Apr  2  2020 '[email protected]'
-rw-r--r--  1 root root  419 Apr  2  2020  bluetooth.target
-rw-r--r--  1 root root  455 Apr  2  2020  boot-complete.target
-rw-r--r--  1 root root 1082 Sep  8  2022  console-getty.service
-rw-r--r--  1 root root 1263 Sep  8  2022 '[email protected]'
lrwxrwxrwx  1 root root    9 Sep  8  2022  cryptdisks-early.service -> /dev/null
lrwxrwxrwx  1 root root    9 Sep  8  2022  cryptdisks.service -> /dev/null
-rw-r--r--  1 root root  465 Apr  2  2020  cryptsetup-pre.target
-rw-r--r--  1 root root  412 Apr  2  2020  cryptsetup.target
lrwxrwxrwx  1 root root   13 Sep  8  2022  ctrl-alt-del.target -> reboot.target
lrwxrwxrwx  1 root root   25 Sep  8  2022  dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service
lrwxrwxrwx  1 root root   23 Sep  8  2022  dbus-org.freedesktop.locale1.service -> systemd-localed.service
lrwxrwxrwx  1 root root   22 Sep  8  2022  dbus-org.freedesktop.login1.service -> systemd-logind.service
lrwxrwxrwx  1 root root   25 Sep  8  2022  dbus-org.freedesktop.timedate1.service -> systemd-timedated.service
-rw-r--r--  1 root root  505 Oct 25 21:09  dbus.service
-rw-r--r--  1 root root  106 Oct 25 21:09  dbus.socket
-rw-r--r--  1 root root 1057 Sep  8  2022  debug-shell.service
lrwxrwxrwx  1 root root   16 Sep  8  2022  default.target -> graphical.target
-rw-r--r--  1 root root  750 Apr  2  2020  dev-hugepages.mount
-rw-r--r--  1 root root  693 Apr  2  2020  dev-mqueue.mount
-rw-r--r--  1 root root  438 Feb 14  2020 '[email protected]'
-rw-r--r--  1 root root  297 Feb 14  2020  e2scrub_all.service
-rw-r--r--  1 root root  251 Feb 14  2020  e2scrub_all.timer
-rw-r--r--  1 root root  246 Feb 14  2020 '[email protected]'
-rw-r--r--  1 root root  550 Feb 14  2020  e2scrub_reap.service
-rw-r--r--  1 root root  797 Sep  8  2022  emergency.service
-rw-r--r--  1 root root  471 Apr  2  2020  emergency.target
-rw-r--r--  1 root root  541 Apr  2  2020  exit.target
-rw-r--r--  1 root root  480 Apr  2  2020  final.target
-rw-r--r--  1 root root  466 Feb  7  2022  fstrim.service
-rw-r--r--  1 root root  205 Feb  7  2022  fstrim.timer
-rw-r--r--  1 root root  506 Apr  2  2020  getty-pre.target
-rw-r--r--  1 root root  342 Aug  8  2022  getty-static.service
-rw-r--r--  1 root root  500 Apr  2  2020  getty.target
drwxr-xr-x  2 root root   43 Nov 24 10:47  getty.target.wants/
-rw-r--r--  1 root root 1975 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root  598 Apr  2  2020  graphical.target
drwxr-xr-x  2 root root   59 Nov 24 10:47  graphical.target.wants/
-rw-r--r--  1 root root  527 Apr  2  2020  halt.target
-rw-r--r--  1 root root  509 Apr  2  2020  hibernate.target
lrwxrwxrwx  1 root root    9 Sep  8  2022  hwclock.service -> /dev/null
-rw-r--r--  1 root root  530 Apr  2  2020  hybrid-sleep.target
-rw-r--r--  1 root root  665 Apr  2  2020  initrd-cleanup.service
-rw-r--r--  1 root root  528 Apr  2  2020  initrd-fs.target
-rw-r--r--  1 root root  815 Apr  2  2020  initrd-parse-etc.service
-rw-r--r--  1 root root  496 Apr  2  2020  initrd-root-device.target
-rw-r--r--  1 root root  501 Apr  2  2020  initrd-root-fs.target
-rw-r--r--  1 root root  584 Apr  2  2020  initrd-switch-root.service
-rw-r--r--  1 root root  777 Apr  2  2020  initrd-switch-root.target
-rw-r--r--  1 root root  813 Apr  2  2020  initrd-udevadm-cleanup-db.service
-rw-r--r--  1 root root  698 Apr  2  2020  initrd.target
-rw-r--r--  1 root root  541 Apr  2  2020  kexec.target
-rw-r--r--  1 root root  716 Sep  8  2022  kmod-static-nodes.service
lrwxrwxrwx  1 root root   28 Sep  8  2022  kmod.service -> systemd-modules-load.service
-rw-r--r--  1 root root  435 Apr  2  2020  local-fs-pre.target
-rw-r--r--  1 root root  482 Apr  2  2020  local-fs.target
drwxr-xr-x  2 root root    3 Sep  8  2022  local-fs.target.wants/
-rw-r--r--  1 root root  445 Apr  2  2020  machine.slice
-rw-r--r--  1 root root  601 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root  173 Jun 16  2020  motd-news.service
-rw-r--r--  1 root root  161 Jun 16  2020  motd-news.timer
-rw-r--r--  1 root root  532 Apr  2  2020  multi-user.target
drwxr-xr-x  2 root root  204 Nov 24 10:56  multi-user.target.wants/
-rw-r--r--  1 root root  505 Apr  2  2020  network-online.target
-rw-r--r--  1 root root  502 Apr  2  2020  network-pre.target
-rw-r--r--  1 root root  521 Apr  2  2020  network.target
-rw-r--r--  1 root root  272 May 25  2021  nfs-client.target
lrwxrwxrwx  1 root root    9 May 25  2021  nfs-common.service -> /dev/null
-rw-r--r--  1 root root  375 May 25  2021  nfs-config.service
-rw-r--r--  1 root root  336 May 25  2021  nfs-idmapd.service
-rw-r--r--  1 root root  567 Aug  4  2016  nfs-utils.service
-rw-r--r--  1 root root  554 Apr  2  2020  nss-lookup.target
-rw-r--r--  1 root root  513 Apr  2  2020  nss-user-lookup.target
-rw-r--r--  1 root root  362 Aug  8  2022  ondemand.service
-rw-r--r--  1 root root  394 Apr  2  2020  paths.target
lrwxrwxrwx  1 root root   15 Sep 18  2019  portmap.service -> rpcbind.service
-rw-r--r--  1 root root  592 Apr  2  2020  poweroff.target
-rw-r--r--  1 root root  417 Apr  2  2020  printer.target
-rw-r--r--  1 root root   98 Aug  4  2016  proc-fs-nfsd.mount
-rw-r--r--  1 root root  745 Apr  2  2020  proc-sys-fs-binfmt_misc.automount
-rw-r--r--  1 root root  718 Apr  2  2020  proc-sys-fs-binfmt_misc.mount
lrwxrwxrwx  1 root root   22 Sep  8  2022  procps.service -> systemd-sysctl.service
-rw-r--r--  1 root root  609 Sep  8  2022  quotaon.service
-rw-r--r--  1 root root  716 Sep  8  2022  rc-local.service
drwxr-xr-x  2 root root   34 Nov 24 10:47  rc-local.service.d/
lrwxrwxrwx  1 root root    9 Sep  8  2022  rc.service -> /dev/null
lrwxrwxrwx  1 root root    9 Sep  8  2022  rcS.service -> /dev/null
-rw-r--r--  1 root root  583 Apr  2  2020  reboot.target
-rw-r--r--  1 root root  549 Apr  2  2020  remote-cryptsetup.target
-rw-r--r--  1 root root  436 Apr  2  2020  remote-fs-pre.target
-rw-r--r--  1 root root  522 Apr  2  2020  remote-fs.target
-rw-r--r--  1 root root  184 Mar 30  2022  rescue-ssh.target
-rw-r--r--  1 root root  788 Sep  8  2022  rescue.service
-rw-r--r--  1 root root  492 Apr  2  2020  rescue.target
drwxr-xr-x  2 root root   59 Nov 24 10:47  rescue.target.wants/
-rw-r--r--  1 root root  391 May 25  2021  rpc-gssd.service
-rw-r--r--  1 root root  497 May 25  2021  rpc-statd-notify.service
-rw-r--r--  1 root root  489 May 25  2021  rpc-statd.service
-rw-r--r--  1 root root  402 May 25  2021  rpc-svcgssd.service
-rw-r--r--  1 root root  626 Sep 18  2019  rpcbind.service
-rw-r--r--  1 root root  325 Sep 18  2019  rpcbind.socket
-rw-r--r--  1 root root  540 Apr  2  2020  rpcbind.target
-rw-r--r--  1 root root  146 May 25  2021  run-rpc_pipefs.mount
lrwxrwxrwx  1 root root   15 Sep  8  2022  runlevel0.target -> poweroff.target
lrwxrwxrwx  1 root root   13 Sep  8  2022  runlevel1.target -> rescue.target
drwxr-xr-x  2 root root    3 Sep  8  2022  runlevel1.target.wants/
lrwxrwxrwx  1 root root   17 Sep  8  2022  runlevel2.target -> multi-user.target
drwxr-xr-x  2 root root    3 Sep  8  2022  runlevel2.target.wants/
lrwxrwxrwx  1 root root   17 Sep  8  2022  runlevel3.target -> multi-user.target
drwxr-xr-x  2 root root    3 Sep  8  2022  runlevel3.target.wants/
lrwxrwxrwx  1 root root   17 Sep  8  2022  runlevel4.target -> multi-user.target
drwxr-xr-x  2 root root    3 Sep  8  2022  runlevel4.target.wants/
lrwxrwxrwx  1 root root   16 Sep  8  2022  runlevel5.target -> graphical.target
drwxr-xr-x  2 root root    3 Sep  8  2022  runlevel5.target.wants/
lrwxrwxrwx  1 root root   13 Sep  8  2022  runlevel6.target -> reboot.target
-rw-r--r--  1 root root 1486 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root  442 Apr  2  2020  shutdown.target
-rw-r--r--  1 root root  402 Apr  2  2020  sigpwr.target
-rw-r--r--  1 root root  460 Apr  2  2020  sleep.target
-rw-r--r--  1 root root  449 Apr  2  2020  slices.target
-rw-r--r--  1 root root  420 Apr  2  2020  smartcard.target
-rw-r--r--  1 root root  348 Mar 21  2020  smartmontools.service
-rw-r--r--  1 root root  396 Apr  2  2020  sockets.target
drwxr-xr-x  2 root root  242 Nov 24 10:56  sockets.target.wants/
-rw-r--r--  1 root root  420 Apr  2  2020  sound.target
-rw-r--r--  1 root root  538 Mar 30  2022  ssh.service
-rw-r--r--  1 root root  216 May  9  2020  ssh.socket
-rw-r--r--  1 root root  318 Mar 30  2022 '[email protected]'
lrwxrwxrwx  1 root root    9 Jan 19  2021  sudo.service -> /dev/null
-rw-r--r--  1 root root  577 Apr  2  2020  suspend-then-hibernate.target
-rw-r--r--  1 root root  503 Apr  2  2020  suspend.target
-rw-r--r--  1 root root  393 Apr  2  2020  swap.target
-rw-r--r--  1 root root  823 Apr  2  2020  sys-fs-fuse-connections.mount
-rw-r--r--  1 root root  830 Sep  8  2022  sys-kernel-config.mount
-rw-r--r--  1 root root  738 Apr  2  2020  sys-kernel-debug.mount
-rw-r--r--  1 root root  764 Apr  2  2020  sys-kernel-tracing.mount
-rw-r--r--  1 root root  558 Apr  2  2020  sysinit.target
drwxr-xr-x  2 root root  865 Nov 24 10:55  sysinit.target.wants/
-rw-r--r--  1 root root 1407 Apr  2  2020  syslog.socket
-rw-r--r--  1 root root  434 Apr  2  2020 'system-systemd\x2dcryptsetup.slice'
-rw-r--r--  1 root root 1415 Apr  2  2020  system-update-cleanup.service
-rw-r--r--  1 root root  543 Apr  2  2020  system-update-pre.target
-rw-r--r--  1 root root  617 Apr  2  2020  system-update.target
-rw-r--r--  1 root root  722 Apr  2  2020  systemd-ask-password-console.path
-rw-r--r--  1 root root  737 Apr  2  2020  systemd-ask-password-console.service
-rw-r--r--  1 root root  650 Apr  2  2020  systemd-ask-password-wall.path
-rw-r--r--  1 root root  742 Apr  2  2020  systemd-ask-password-wall.service
-rw-r--r--  1 root root  719 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root 1175 Sep  8  2022  systemd-binfmt.service
-rw-r--r--  1 root root  678 Sep  8  2022  systemd-bless-boot.service
-rw-r--r--  1 root root  718 Sep  8  2022  systemd-boot-check-no-failures.service
-rw-r--r--  1 root root 1371 Apr  2  2020  systemd-boot-system-token.service
-rw-r--r--  1 root root  556 Apr  2  2020  systemd-exit.service
-rw-r--r--  1 root root  740 Sep  8  2022  systemd-fsck-root.service
-rw-r--r--  1 root root  741 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root  551 Sep  8  2022  systemd-fsckd.service
-rw-r--r--  1 root root  540 Sep  8  2022  systemd-fsckd.socket
-rw-r--r--  1 root root  579 Apr  2  2020  systemd-halt.service
-rw-r--r--  1 root root  671 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root  541 Sep  8  2022  systemd-hibernate.service
-rw-r--r--  1 root root 1157 Nov 11 16:20  systemd-hostnamed.service
-rw-r--r--  1 root root  813 Sep  8  2022  systemd-hwdb-update.service
-rw-r--r--  1 root root  559 Sep  8  2022  systemd-hybrid-sleep.service
-rw-r--r--  1 root root  566 Sep  8  2022  systemd-initctl.service
-rw-r--r--  1 root root  546 Apr  2  2020  systemd-initctl.socket
-rw-r--r--  1 root root  773 Apr  2  2020  systemd-journal-flush.service
-rw-r--r--  1 root root  686 Sep  8  2022  systemd-journald-audit.socket
-rw-r--r--  1 root root 1130 Apr  2  2020  systemd-journald-dev-log.socket
-rw-r--r--  1 root root  597 Apr  2  2020 '[email protected]'
-rw-r--r--  1 root root 1558 Sep  8  2022  systemd-journald.service
-rw-r--r--  1 root root  882 Apr  2  2020  systemd-journald.socket
-rw-r--r--  1 root root 1466 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root  738 Apr  2  2020 '[email protected]'
-rw-r--r--  1 root root  592 Apr  2  2020  systemd-kexec.service
-rw-r--r--  1 root root 1147 Sep  8  2022  systemd-localed.service
-rw-r--r--  1 root root 2087 Sep  8  2022  systemd-logind.service
-rw-r--r--  1 root root  728 Apr  2  2020  systemd-machine-id-commit.service
-rw-r--r--  1 root root 1042 Sep  8  2022  systemd-modules-load.service
-rw-r--r--  1 root root  635 Sep  8  2022  systemd-network-generator.service
-rw-r--r--  1 root root  753 Nov 11 16:20  systemd-networkd-wait-online.service
-rw-r--r--  1 root root 1999 Nov 11 16:20  systemd-networkd.service
-rw-r--r--  1 root root  633 Apr  2  2020  systemd-networkd.socket
-rw-r--r--  1 root root  556 Apr  2  2020  systemd-poweroff.service
-rw-r--r--  1 root root 1033 Sep  8  2022  systemd-pstore.service
-rw-r--r--  1 root root  655 Sep  8  2022  systemd-quotacheck.service
-rw-r--r--  1 root root 1059 Sep  8  2022  systemd-random-seed.service
-rw-r--r--  1 root root  551 Apr  2  2020  systemd-reboot.service
-rw-r--r--  1 root root  767 Sep  8  2022  systemd-remount-fs.service
-rw-r--r--  1 root root 1731 Sep  8  2022  systemd-resolved.service
-rw-r--r--  1 root root  717 Sep  8  2022  systemd-rfkill.service
-rw-r--r--  1 root root  726 Apr  2  2020  systemd-rfkill.socket
-rw-r--r--  1 root root  596 Sep  8  2022  systemd-suspend-then-hibernate.service
-rw-r--r--  1 root root  537 Sep  8  2022  systemd-suspend.service
-rw-r--r--  1 root root  693 Sep  8  2022  systemd-sysctl.service
-rw-r--r--  1 root root  695 Apr  2  2020  systemd-sysusers.service
-rw-r--r--  1 root root 1196 Sep  8  2022  systemd-time-wait-sync.service
-rw-r--r--  1 root root 1140 Nov 11 16:20  systemd-timedated.service
-rw-r--r--  1 root root 1483 Nov 11 16:20  systemd-timesyncd.service
-rw-r--r--  1 root root  658 Apr  2  2020  systemd-tmpfiles-clean.service
-rw-r--r--  1 root root  490 Apr  2  2020  systemd-tmpfiles-clean.timer
-rw-r--r--  1 root root  739 Apr  2  2020  systemd-tmpfiles-setup-dev.service
-rw-r--r--  1 root root  779 Apr  2  2020  systemd-tmpfiles-setup.service
-rw-r--r--  1 root root  852 Apr  2  2020  systemd-udev-settle.service
-rw-r--r--  1 root root  753 Apr  2  2020  systemd-udev-trigger.service
-rw-r--r--  1 root root  635 Apr  2  2020  systemd-udevd-control.socket
-rw-r--r--  1 root root  610 Apr  2  2020  systemd-udevd-kernel.socket
-rw-r--r--  1 root root 1151 Sep  8  2022  systemd-udevd.service
-rw-r--r--  1 root root  797 Sep  8  2022  systemd-update-utmp-runlevel.service
-rw-r--r--  1 root root  794 Sep  8  2022  systemd-update-utmp.service
-rw-r--r--  1 root root  628 Sep  8  2022  systemd-user-sessions.service
-rw-r--r--  1 root root  690 Sep  8  2022  systemd-volatile-root.service
-rw-r--r--  1 root root  426 Apr  2  2020  time-set.target
-rw-r--r--  1 root root  479 Apr  2  2020  time-sync.target
-rw-r--r--  1 root root  445 Apr  2  2020  timers.target
drwxr-xr-x  2 root root   51 Nov 24 10:47  timers.target.wants/
lrwxrwxrwx  1 root root   21 Sep  8  2022  udev.service -> systemd-udevd.service
-rw-r--r--  1 root root  457 Apr  2  2020  umount.target
drwxr-xr-x  2 root root   39 Nov 24 10:47  user-.slice.d/
-rw-r--r--  1 root root  688 Sep  8  2022 '[email protected]'
-rw-r--r--  1 root root  432 Apr  2  2020  user.slice
-rw-r--r--  1 root root  748 Sep  8  2022 '[email protected]'
drwxr-xr-x  2 root root   35 Nov 24 10:47 '[email protected]'/
lrwxrwxrwx  1 root root    9 Sep  8  2022  x11-common.service -> /dev/null
-rw-r--r--  1 root root  496 Oct 12  2021  zfs-import-cache.service
-rw-r--r--  1 root root  466 Oct 12  2021  zfs-import-scan.service
lrwxrwxrwx  1 root root    9 Oct 12  2021  zfs-import.service -> /dev/null
-rw-r--r--  1 root root  101 Oct 12  2021  zfs-import.target
-rw-r--r--  1 root root  356 Oct 12  2021  zfs-load-module.service
-rw-r--r--  1 root root  373 Oct 12  2021  zfs-mount.service
-rw-r--r--  1 root root  435 Oct 12  2021  zfs-share.service
-rw-r--r--  1 root root  250 Oct 12  2021  zfs-volume-wait.service
-rw-r--r--  1 root root  135 Oct 12  2021  zfs-volumes.target
-rw-r--r--  1 root root   76 Oct 12  2021  zfs.target

4.2 配置文件的状态

这个列表显示每个配置文件的状态,一共有四种。

  • enabled:已建立启动链接
  • disabled:没建立启动链接
  • static:该配置文件没有[Install]部分(无法执行),只能作为其他配置文件的依赖
  • masked:该配置文件被禁止建立启动链接
  • transient: 临时的,可限制此服务运行时所用资源
root@node:~/PKG# systemctl list-unit-files
UNIT FILE                              STATE           VENDOR PRESET
proc-sys-fs-binfmt_misc.automount      static          enabled
dev-hugepages.mount                    static          enabled
dev-mqueue.mount                       static          enabled
proc-fs-nfsd.mount                     static          enabled
proc-sys-fs-binfmt_misc.mount          disabled        enabled

root@node:~/PKG# systemctl list-unit-files --type=service

一旦修改配置文件,就要让 SystemD 重新加载配置文件,然后重新启动,否则修改不会生效。

systemctl daemon-reload
systemctl restart httpd.service

4.3 配置文件的格式

配置文件就是普通的文本文件,可用文本编辑器打开。systemctl cat 命令可查看配置文件内容。注意键值对的等号两侧不能有空格。

root@node:~# systemctl cat app-start-abc.service
# /run/systemd/transient/app-start-abc.service
# This is a transient unit file, created programmatically via the systemd API. Do not e>
[Unit]
Description=run abc

[Service]
KillMode=control-group
Restart=always
RestartSec=3s
RestartPreventExitStatus=255
LimitNOFILE=65535
LimitNOFILE=65535
ExecStart=
ExecStart="/home/node/Applications/abc.app.dpk.mnt/run.sh"

# /run/systemd/transient/app-start-abc.service.d/50-CPUShares.conf
# This is a drop-in unit file extension, created via "systemctl set-property"
# or an equivalent operation. Do not edit.
[Service]
CPUShares=500

4.4 配置文件的区块

Unit 配置文件的完整字段清单,请参考官方文档。

4.4.1 [Unit]

[Unit] 区块通常是配置文件的第一个区块,用来定义 Unit 的元数据,以及配置与其他 Unit 的关系。它的主要字段如下:

  • Description:简短描述
  • Documentation:文档地址
  • Requires:当前 Unit 依赖的其他 Unit,如果它们没有运行,当前 Unit 会启动失败
  • Wants:与当前 Unit 配合的其他 Unit,如果它们没有运行,当前 Unit 不会启动失败
  • BindsTo:与 Requires 类似,它指定的 Unit 如果退出,会导致当前 Unit 停止运行
  • Before:此 Unit 必须在指定的 Unit 之前启动
  • After:此 Unit 必须在指定的 Unit 之后启动
  • Conflicts:这里指定的 Unit 不能与当前 Unit 同时运行
  • Condition…:当前 Unit 运行必须满足的条件,否则不会运行
  • Assert…:当前 Unit 运行必须满足的条件,否则会报启动失败

4.4.2 [Install]

[Install] 通常是配置文件的最后一个区块,用来定义如何启动,以及是否开机启动。它的主要字段如下。

  • WantedBy:它的值是一个或多个 Target,当前 Unit 激活时(enable)符号链接会放入 /etc/systemd/system 目录下面以 Target 名 + .wants后缀构成的子目录中
  • RequiredBy:它的值是一个或多个 Target,当前 Unit 激活时,ll符号链接会放入 /etc/systemd/system 目录下面以 Target 名 + .required后缀构成的子目录中
  • Alias:当前 Unit 可用于启动的别名
  • Also:当前 Unit 激活(enable)时,会被同时激活的其他 Unit
root@node:/etc/systemd/system# ll | grep wants
drwxr-xr-x 2 root root   43 Nov 11 16:20 default.target.wants/
drwxr-xr-x 2 root root   41 Nov 24 10:47 getty.target.wants/
drwxr-xr-x 2 root root  394 Nov 11 16:20 multi-user.target.wants/
drwxr-xr-x 2 root root   40 Nov 24 10:51 remote-fs.target.wants/
drwxr-xr-x 2 root root   37 Nov 11 16:20 sockets.target.wants/
drwxr-xr-x 2 root root   78 Nov 11 16:20 sysinit.target.wants/
drwxr-xr-x 2 root root  137 Nov 11 16:20 timers.target.wants/
drwxr-xr-x 2 root root   47 Nov 11 16:20 zfs-import.target.wants/
drwxr-xr-x 2 root root   46 Nov 11 16:20 zfs-mount.service.wants/
drwxr-xr-x 2 root root   46 Nov 11 16:20 zfs-volumes.target.wants/
drwxr-xr-x 2 root root  147 Nov 11 16:20 zfs.target.wants/

root@node:/etc/systemd/system# ll sockets.target.wants/
total 4
drwxr-xr-x 2 root root   37 Nov 11 16:20 ./
drwxr-xr-x 1 root root 4096 Jan  5 14:38 ../
lrwxrwxrwx 1 root root    9 Nov 11 16:20 rpcbind.socket -> /dev/null

4.4.3 [Service]

[Service] 区块用来 Service 的配置,只有 Service 类型的 Unit 才有这个区块。它的主要字段如下:

  • Type:定义启动时的进程行为。它有以下几种值。
    • Type=simple:默认值,执行ExecStart指定的命令,启动主进程
    • Type=forking:以 fork 方式从父进程创建子进程,创建后父进程会立即退出
    • Type=oneshot:一次性进程,Systemd 会等当前服务退出,再继续往下执行
    • Type=dbus:当前服务通过 D-Bus 启动
    • Type=notify:当前服务启动完毕,会通知 Systemd,再继续往下执行
    • Type=idle:若有其他任务执行完毕,当前服务才会运行
  • ExecStart:启动当前服务的命令
  • ExecStartPre:启动当前服务之前执行的命令
  • ExecStartPost:启动当前服务之后执行的命令
  • ExecReload:重启当前服务时执行的命令
  • ExecStop:停止当前服务时执行的命令
  • ExecStopPost:停止当其服务之后执行的命令
  • RestartSec:自动重启当前服务间隔的秒数
  • Restart:定义何种情况 Systemd 会自动重启当前服务,可能的值包括always(总是重启)、on-success、on-failure、on-abnormal、on-abort、on-watchdog
  • TimeoutSec:定义 Systemd 停止当前服务之前等待的秒数
  • Environment:指定环境变量

五、Target 是 Unit 组

启动计算机的时候,需要启动大量的 Unit。如果每一次启动,都要一一写明本次启动需要哪些 Unit,显然非常不方便。Systemd 的解决方案就是 Target。

简单说,Target 就是一个 Unit 组,包含许多相关的 Unit 。启动某个 Target 的时候,Systemd 就会启动里面所有的 Unit。从这个意义上说,Target 这个概念类似于"状态点",启动某个 Target 就好比启动到某种状态。

传统的 init 启动模式里面,有 RunLevel 的概念,跟 Target 的作用很类似。不同的是,RunLevel 是互斥的,不可能多个 RunLevel 同时启动,但是多个 Target 可以同时启动。

# 查看当前系统的所有 Target
root@node:/etc/systemd/system# systemctl list-unit-files --type=target
UNIT FILE                     STATE    VENDOR PRESET
basic.target                  static   enabled
bluetooth.target              static   enabled
initrd-switch-root.target     static   enabled
multi-user.target             static   enabled
network-online.target         static   enabled
# 查看一个 Target 包含的所有 Unit
root@node:/etc/systemd/system# systemctl list-dependencies multi-user.target
multi-user.target
● ├─dbus.service
● ├─delinux-entry-app.service
● ├─delinux-entry-sys.service
● ├─systemd-ask-password-wall.path
● ├─systemd-networkd.service
● ├─systemd-resolved.service
● ├─systemd-update-utmp-runlevel.service
● ├─systemd-user-sessions.service
● ├─basic.target
● │ ├─tmp.mount
● │ ├─paths.target
● │ ├─slices.target
● │ │ ├─-.slice
● │ │ └─system.slice
● │ ├─sockets.target
● │ │ ├─dbus.socket
● │ │ ├─systemd-initctl.socket
● │ │ ├─systemd-journald-audit.socket
● │ │ ├─systemd-journald-dev-log.socket
● │ │ ├─systemd-journald.socket
● │ │ ├─systemd-udevd-control.socket
● │ │ └─systemd-udevd-kernel.socket
● │ ├─sysinit.target
● │ │ ├─dev-hugepages.mount
● │ │ ├─dev-mqueue.mount
● │ │ ├─kmod-static-nodes.service
● │ │ ├─proc-sys-fs-binfmt_misc.automount
● │ │ ├─sys-fs-fuse-connections.mount
● │ │ ├─sys-kernel-config.mount
● │ │ ├─sys-kernel-debug.mount
● │ │ ├─sys-kernel-tracing.mount
● │ │ ├─systemd-ask-password-console.path
● │ │ ├─systemd-binfmt.service
● │ │ ├─systemd-boot-system-token.service
● │ │ ├─systemd-hwdb-update.service
● │ │ ├─systemd-journal-flush.service
● │ │ ├─systemd-journald.service
● │ │ ├─systemd-machine-id-commit.service
● │ │ ├─systemd-modules-load.service
● │ │ ├─systemd-pstore.service
● │ │ ├─systemd-random-seed.service
● │ │ ├─systemd-sysctl.service
● │ │ ├─systemd-sysusers.service
● │ │ ├─systemd-tmpfiles-setup-dev.service
● │ │ ├─systemd-tmpfiles-setup.service
● │ │ ├─systemd-udev-trigger.service
● │ │ ├─systemd-udevd.service
● │ │ ├─systemd-update-utmp.service
● │ │ ├─cryptsetup.target
● │ │ ├─local-fs.target
● │ │ │ └─systemd-remount-fs.service
● │ │ └─swap.target
● │ └─timers.target
● │   ├─e2scrub_all.timer
● │   ├─fstrim.timer
● │   ├─motd-news.timer
● │   └─systemd-tmpfiles-clean.timer
● ├─getty.target
● │ ├─getty-static.service
● │ ├─[email protected]
● │ └─[email protected]
● ├─nfs-client.target
● │ ├─nfs-blkmap.service
● │ ├─rpc-gssd.service
● │ └─remote-fs-pre.target
● ├─remote-fs.target
● │ └─nfs-client.target
● │   ├─nfs-blkmap.service
● │   ├─rpc-gssd.service
● │   └─remote-fs-pre.target
● └─zfs.target
# 查看启动时的默认 Target
root@node:/etc/systemd/system# systemctl get-default
graphical.target

# 设置启动时的默认 Target
systemctl set-default multi-user.target

# 切换 Target 时,默认不关闭前一个 Target 启动的进程,
# systemctl isolate 命令改变这种行为,
# 关闭前一个 Target 里面所有不属于后一个 Target 的进程
systemctl isolate multi-user.target

Target 与 传统 RunLevel 的对应关系如下:

Traditional runlevel      New target name     Symbolically linked to...
Runlevel 0           |    runlevel0.target -> poweroff.target
Runlevel 1           |    runlevel1.target -> rescue.target
Runlevel 2           |    runlevel2.target -> multi-user.target
Runlevel 3           |    runlevel3.target -> multi-user.target
Runlevel 4           |    runlevel4.target -> multi-user.target
Runlevel 5           |    runlevel5.target -> graphical.target
Runlevel 6           |    runlevel6.target -> reboot.target

它与init进程的主要差别如下:

  • 默认的 RunLevel(在/etc/inittab文件设置)现在被默认的 Target 取代,位置是 /etc/systemd/system/default.target,通常符号链接到graphical.target(图形界面)或者multi-user.target(多用户命令行)。
  • 启动脚本的位置,以前是/etc/init.d目录,符号链接到不同的 RunLevel 目录(如/etc/rc3.d、/etc/rc5.d等),现在则存放在 /lib/systemd/system 和 /etc/systemd/system 目录。
  • 配置文件的位置,以前init进程的配置文件是/etc/inittab,各种服务的配置文件存放在/etc/sysconfig目录。现在的配置文件主要存放在 /lib/systemd 目录,在 /etc/systemd 目录里面的修改可以覆盖原始设置。
root@node:/etc/systemd/system# ll /lib/systemd
total 8334
drwxr-xr-x 1 root root    4096 Nov 11 16:20 ./
drwxr-xr-x 1 root root    4096 May 31  2022 ../
drwxr-xr-x 3 root root      26 Nov 24 10:47 boot/
drwxr-xr-x 2 root root     339 Nov 24 10:47 catalog/
-rw-r--r-- 1 root root 2446488 Sep  8  2022 libsystemd-shared-245.so
drwxr-xr-x 2 root root     266 Nov 24 10:55 network/
drwxr-xr-x 2 root root      47 Nov 24 10:47 ntp-units.d/
-rw-r--r-- 1 root root     701 Sep  8  2022 resolv.conf
drwxr-xr-x 2 root root      39 Nov 24 10:51 scripts/
-rwxr-xr-x 1 root root    1246 Sep  8  2022 set-cpufreq*
drwxr-xr-x 1 root root    4096 Apr 23 11:49 system/
drwxr-xr-x 2 root root     452 Nov 24 18:51 system-generators/
drwxr-xr-x 2 root root      61 Nov 24 18:51 system-preset/
drwxr-xr-x 2 root root       3 Sep  8  2022 system-shutdown/
drwxr-xr-x 2 root root       3 Sep  8  2022 system-sleep/
-rwxr-xr-x 1 root root 1551488 Sep  8  2022 systemd*
-rwxr-xr-x 1 root root   10240 Sep  8  2022 systemd-ac-power*
-rwxr-xr-x 1 root root   22520 Sep  8  2022 systemd-backlight*
-rwxr-xr-x 1 root root   14408 Sep  8  2022 systemd-binfmt*
-rwxr-xr-x 1 root root   22632 Sep  8  2022 systemd-bless-boot*
-rwxr-xr-x 1 root root   10240 Sep  8  2022 systemd-boot-check-no-failures*
-rwxr-xr-x 1 root root   10160 Sep  8  2022 systemd-cgroups-agent*
-rwxr-xr-x 1 root root   31024 Sep  8  2022 systemd-cryptsetup*
-rwxr-xr-x 1 root root   14448 Sep  8  2022 systemd-dissect*
-rwxr-xr-x 1 root root   22456 Sep  8  2022 systemd-fsck*
-rwxr-xr-x 1 root root   22528 Sep  8  2022 systemd-fsckd*
-rwxr-xr-x 1 root root   18432 Sep  8  2022 systemd-growfs*
-rwxr-xr-x 1 root root   10160 Sep  8  2022 systemd-hibernate-resume*
-rwxr-xr-x 1 root root   26624 Sep  8  2022 systemd-hostnamed*
-rwxr-xr-x 1 root root   14336 Sep  8  2022 systemd-initctl*
-rwxr-xr-x 1 root root  149552 Sep  8  2022 systemd-journald*
-rwxr-xr-x 1 root root   38912 Sep  8  2022 systemd-localed*
-rwxr-xr-x 1 root root  252112 Sep  8  2022 systemd-logind*
-rwxr-xr-x 1 root root   10160 Sep  8  2022 systemd-makefs*
-rwxr-xr-x 1 root root   14440 Sep  8  2022 systemd-modules-load*
-rwxr-xr-x 1 root root   30720 Sep  8  2022 systemd-network-generator*
-rwxr-xr-x 1 root root 2218920 Sep  8  2022 systemd-networkd*
-rwxr-xr-x 1 root root   26808 Sep  8  2022 systemd-networkd-wait-online*
-rwxr-xr-x 1 root root   18456 Sep  8  2022 systemd-pstore*
-rwxr-xr-x 1 root root   10240 Sep  8  2022 systemd-quotacheck*
-rwxr-xr-x 1 root root   18352 Sep  8  2022 systemd-random-seed*
-rwxr-xr-x 1 root root   18456 Sep  8  2022 systemd-remount-fs*
-rwxr-xr-x 1 root root   10160 Sep  8  2022 systemd-reply-password*
-rwxr-xr-x 1 root root  399472 Sep  8  2022 systemd-resolved*
-rwxr-xr-x 1 root root   18432 Sep  8  2022 systemd-rfkill*
-rwxr-xr-x 1 root root   47168 Sep  8  2022 systemd-shutdown*
-rwxr-xr-x 1 root root   18576 Sep  8  2022 systemd-sleep*
-rwxr-xr-x 1 root root   22528 Sep  8  2022 systemd-socket-proxyd*
-rwxr-xr-x 1 root root   10160 Sep  8  2022 systemd-sulogin-shell*
-rwxr-xr-x 1 root root   18584 Sep  8  2022 systemd-sysctl*
-rwxr-xr-x 1 root root    1360 Jul 20  2022 systemd-sysv-install*
-rwxr-xr-x 1 root root   14256 Sep  8  2022 systemd-time-wait-sync*
-rwxr-xr-x 1 root root   38984 Sep  8  2022 systemd-timedated*
-rwxr-xr-x 1 root root   47104 Sep  8  2022 systemd-timesyncd*
-rwxr-xr-x 1 root root  740368 Sep  8  2022 systemd-udevd*
-rwxr-xr-x 1 root root   14360 Sep  8  2022 systemd-update-utmp*
-rwxr-xr-x 1 root root   14280 Sep  8  2022 systemd-user-runtime-dir*
-rwxr-xr-x 1 root root   10160 Sep  8  2022 systemd-user-sessions*
-rwxr-xr-x 1 root root   14392 Sep  8  2022 systemd-veritysetup*
-rwxr-xr-x 1 root root   14256 Sep  8  2022 systemd-volatile-root*
drwxr-xr-x 3 root root     527 Nov 24 10:52 user/
drwxr-xr-x 2 root root      57 Nov 24 10:47 user-environment-generators/
drwxr-xr-x 2 root root       3 Sep  8  2022 user-generators/
drwxr-xr-x 2 root root      40 Nov 24 10:47 user-preset/
root@node:/etc/systemd/system# ll /etc/systemd/
total 27
drwxr-xr-x 1 root root 4096 Jan  6 14:34 ./
drwxr-xr-x 1 root root 4096 Jan  5 10:38 ../
-rw-r--r-- 1 root root 1029 Feb 20 11:32 journald.conf
-rw-r--r-- 1 root root 1042 Sep  8  2022 logind.conf
lrwxrwxrwx 1 root root   54 Nov 11 16:20 network -> /home/node/SysData/rw_rootfs/etc/systemd/network//
-rw-r--r-- 1 root root  584 Apr  2  2020 networkd.conf
-rw-r--r-- 1 root root  529 Apr  2  2020 pstore.conf
-rw-r--r-- 1 root root  642 Sep  8  2022 resolved.conf
-rw-r--r-- 1 root root  790 Apr  2  2020 sleep.conf
drwxr-xr-x 1 root root 4096 Apr 23 22:49 system/
-rw-r--r-- 1 root root 2180 Jan 31 10:32 system.conf
lrwxrwxrwx 1 root root   60 Nov 11 16:20 timesyncd.conf -> /home/node/SysData/rw_rootfs/etc/systemd/timesyncd.conf
drwxr-xr-x 2 root root    3 Sep  8  2022 user/
-rw-r--r-- 1 root root 1185 Sep  8  2022 user.conf

六、journalctl

Systemd 统一管理所有 Unit 的启动日志。带来的好处就是,可以只用 journalctl 一个命令,查看所有日志(内核日志和应用日志)。日志的配置文件是 /etc/systemd/journald.conf。用法如下:

# 查看所有日志(默认情况下 ,只保存本次启动的日志)
journalctl

# 查看内核日志(不显示应用日志)
journalctl -k

# 查看系统本次启动的日志
journalctl -b
journalctl -b -0

# 查看上一次启动的日志(需更改设置)
journalctl -b -1

# 查看指定时间的日志
journalctl --since="2012-10-30 18:17:16"
journalctl --since "20 min ago"
journalctl --since yesterday
journalctl --since "2015-01-10" --until "2015-01-11 03:00"
journalctl --since 09:00 --until "1 hour ago"

# 显示尾部的最新10行日志
journalctl -n

# 显示尾部指定行数的日志
journalctl -n 20

# 实时滚动显示最新日志
journalctl -f

# 查看指定服务的日志
journalctl /usr/lib/systemd/systemd

# 查看指定进程的日志
journalctl _PID=1

# 查看某个路径的脚本的日志
journalctl /usr/bin/bash

# 查看指定用户的日志
journalctl _UID=33 --since today

# 查看某个 Unit 的日志
journalctl -u nginx.service
journalctl -u nginx.service --since today

# 实时滚动显示某个 Unit 的最新日志
journalctl -u nginx.service -f

# 合并显示多个 Unit 的日志
$ journalctl -u nginx.service -u php-fpm.service --since today

# 查看指定优先级(及其以上级别)的日志,共有8级
# 0: emerg
# 1: alert
# 2: crit
# 3: err
# 4: warning
# 5: notice
# 6: info
# 7: debug
journalctl -p err -b

# 日志默认分页输出,--no-pager 改为正常的标准输出
journalctl --no-pager

# 以 JSON 格式(单行)输出
journalctl -b -u nginx.service -o json

# 以 JSON 格式(多行)输出,可读性更好
journalctl -b -u nginx.serviceqq
 -o json-pretty

# 显示日志占据的硬盘空间
journalctl --disk-usage

# 指定日志文件占据的最大空间
journalctl --vacuum-size=1G

# 指定日志文件保存多久
journalctl --vacuum-time=1years

七、启动

7.1 开机启动

对于那些支持 Systemd 的软件,安装的时候,会自动在/usr/lib/systemd/system目录添加一个配置文件。

如果你想让该软件开机启动,则 systemctl enable httpd 。这相当于在/etc/systemd/system目录添加一个符号链接,指向/usr/lib/systemd/system里面的httpd.service文件。

这是因为开机时,Systemd只执行/etc/systemd/system目录里面的配置文件。这也意味着,如果把修改后的配置文件放在该目录,就可以达到覆盖原始配置的效果。

7.2 启停服务

设置开机启动以后,软件并不会立即启动,必须等到下一次开机。如果想现在就运行该软件,那么要执行 systemctl start httpd

执行上面的命令以后,有可能启动失败,因此要用systemctl status命令查看一下该服务的状态,其输出内容如下:

  • Loaded行:配置文件的位置,是否设为开机启动
  • Active行:表示正在运行
  • Main PID行:主进程 ID
  • Status行:由应用本身(这里是 httpd )提供的软件当前状态
  • CGroup块:应用的所有子进程
  • 日志块:应用的日志
systemctl status httpd

httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since 金 2014-12-05 12:18:22 JST; 7min ago
 Main PID: 4349 (httpd)
   Status: "Total requests: 1; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─4349 /usr/sbin/httpd -DFOREGROUND
           ├─4350 /usr/sbin/httpd -DFOREGROUND
           ├─4351 /usr/sbin/httpd -DFOREGROUND
           ├─4352 /usr/sbin/httpd -DFOREGROUND
           ├─4353 /usr/sbin/httpd -DFOREGROUND
           └─4354 /usr/sbin/httpd -DFOREGROUND

12月 05 12:18:22 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
12月 05 12:18:22 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
12月 05 12:22:40 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

终止正在运行的服务,需要执行 systemctl stop httpd.service。有时该命令可能没有响应,服务停不下来。这时候就不得不"杀进程"了,向正在运行的进程发出kill信号:systemctl kill httpd.service

此外,重启服务要执行 systemctl restart httpd.service

你可能感兴趣的:(Linux,实战,linux,运维,服务器)