Home systemd 系统状态检查
Post
Cancel

systemd 系统状态检查

bootup检查,系统状态查看

在linux bootup时,会显示大量信息,可以使用 systemctl 命令查看所有服务,磁盘,挂载,定时器等的状态信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
$ systemctl
  UNIT                                                                                     LOAD   ACTIVE     SUB       DESCRIPTION             >
  proc-sys-fs-binfmt_misc.automount                                                        loaded active     running   Arbitrary Executable Fil>
  dev-fuse.device                                                                          loaded activating tentative /dev/fuse               >
  sys-devices-pci0000:00-0000:00:11.5-ata5-host4-target4:0:0-4:0:0:0-block-sda-sda1.device loaded active     plugged   WDC_WUH721816ALE6L4 1   >
  sys-devices-pci0000:00-0000:00:11.5-ata5-host4-target4:0:0-4:0:0:0-block-sda.device      loaded active     plugged   WDC_WUH721816ALE6L4     >
  sys-devices-pci0000:00-0000:00:14.0-usb1-1\x2d4-1\x2d4:1.1-ttyUSB1-tty-ttyUSB1.device    loaded active     plugged   FT4232H Quad HS USB-UART>
  sys-devices-pci0000:00-0000:00:14.0-usb1-1\x2d4-1\x2d4:1.2-ttyUSB2-tty-ttyUSB2.device    loaded active     plugged   FT4232H Quad HS USB-UART>
  sys-devices-pci0000:00-0000:00:14.0-usb1-1\x2d4-1\x2d4:1.3-ttyUSB3-tty-ttyUSB3.device    loaded active     plugged   FT4232H Quad HS USB-UART>
  sys-devices-pci0000:64-0000:64:02.0-0000:65:00.0-nvme-nvme0-nvme0n1-nvme0n1p1.device     loaded active     plugged   WD_BLACK SN770 500GB EFI>
  sys-devices-pci0000:64-0000:64:02.0-0000:65:00.0-nvme-nvme0-nvme0n1-nvme0n1p2.device     loaded active     plugged   WD_BLACK SN770 500GB 2  >
  sys-devices-pci0000:64-0000:64:02.0-0000:65:00.0-nvme-nvme0-nvme0n1-nvme0n1p3.device     loaded active     plugged   WD_BLACK SN770 500GB 3  >
  sys-devices-pci0000:64-0000:64:02.0-0000:65:00.0-nvme-nvme0-nvme0n1-nvme0n1p4.device     loaded active     plugged   WD_BLACK SN770 500GB 4  >
  sys-devices-pci0000:64-0000:64:02.0-0000:65:00.0-nvme-nvme0-nvme0n1.device               loaded active     plugged   WD_BLACK SN770 500GB   

  ...

    -.mount                                                                                  loaded active     mounted   Root Mount              >
  boot-efi.mount                                                                           loaded active     mounted   /boot/efi               >
  data.mount                                                                               loaded active     mounted   /data                   >
  dev-hugepages.mount                                                                      loaded active     mounted   Huge Pages File System  >
  dev-mqueue.mount                                                                         loaded active     mounted   POSIX Message Queue File>
  home-hjm-thinclient_drives.mount                                                         loaded active     mounted   /home/hjm/thinclient_dri>
  proc-sys-fs-binfmt_misc.mount                                                            loaded active     mounted   Arbitrary Executable Fil>
  run-snapd-ns-snap\x2dstore.mnt.mount                                                     loaded active     mounted   /run/snapd/ns/snap-store>
  run-snapd-ns.mount                                                                       loaded active     mounted   /run/snapd/ns           >
  run-user-1001-doc.mount                                                                  loaded active     mounted   /run/user/1001/doc      >
  run-user-1001-gvfs.mount                                                                 loaded active     mounted   /run/user/1001/gvfs     >
  run-user-1001.mount                                                                      loaded active     mounted   /run/user/1001          

  ...

    init.scope                                                                               loaded active     running   System and Service Manag>
  session-11.scope                                                                         loaded active     running   Session 11 of user test  >
  session-16.scope                                                                         loaded active     running   Session 16 of user test  >
  session-17.scope                                                                         loaded active     running   Session 17 of user test  >
  session-2.scope                                                                          loaded active     running   Session 2 of user test    >
  session-221.scope                                                                        loaded active     running   Session 221 of user test >
  session-222.scope                                                                        loaded active     running   Session 222 of user test >
  session-230.scope                                                                        loaded active     running   Session 230 of user test  >

  ...

  getty@tty1.service                                                                       loaded active     running   Getty on tty1           >
  irqbalance.service                                                                       loaded active     running   irqbalance daemon       >
  kerneloops.service                                                                       loaded active     running   Tool to automatically co>
  keyboard-setup.service                                                                   loaded active     exited    Set the console keyboard>
  kmod-static-nodes.service                                                                loaded active     exited    Create list of static de>
  lightdm.service                                                                          loaded active     running   Light Display Manager   >
  ModemManager.service                                                                     loaded active     running   Modem Manager           >
  networkd-dispatcher.service                                                              loaded active     running   Dispatcher daemon for sy>
  NetworkManager-wait-online.service                                                       loaded active     exited    Network Manager Wait Onl>
  
  ...

  basic.target                                                                             loaded active     active    Basic System            >
  cryptsetup.target                                                                        loaded active     active    Local Encrypted Volumes >
  getty-pre.target                                                                         loaded active     active    Login Prompts (Pre)     >
  getty.target                                                                             loaded active     active    Login Prompts           >
  graphical.target                                                                         loaded active     active    Graphical Interface     >
  local-fs-pre.target                                                                      loaded active     active    Local File Systems (Pre)>
  local-fs.target                                                                          loaded active     active    Local File Systems      >
  multi-user.target                                                                        loaded active     active    Multi-User System       >

  ...

  anacron.timer                                                                            loaded active     waiting   Trigger anacron every ho>
  apt-daily-upgrade.timer                                                                  loaded active     waiting   Daily apt upgrade and cl>
  apt-daily.timer                                                                          loaded active     waiting   Daily apt download activ>
  e2scrub_all.timer                                                                        loaded active     waiting   Periodic ext4 Online Met>
  fstrim.timer                                                                             loaded active     waiting   Discard unused blocks on>

  ...
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.

285 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

如上所示,可以看到所有服务的简单状态信息,可以进一步查看详细信息,由于是当服务出错时。 使用 systemctl status ,如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ systemctl status smbd.service 
● smbd.service - Samba SMB Daemon
     Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-08-30 13:44:38 CST; 6 days ago
       Docs: man:smbd(8)
             man:samba(7)
             man:smb.conf(5)
    Process: 1893 ExecStartPre=/usr/share/samba/update-apparmor-samba-profile (code=exited, status=0/SUCCESS)
   Main PID: 1917 (smbd)
     Status: "smbd: ready to serve connections..."
      Tasks: 4 (limit: 308968)
     Memory: 32.8M
     CGroup: /system.slice/smbd.service
             ├─1917 /usr/sbin/smbd --foreground --no-process-group
             ├─1929 /usr/sbin/smbd --foreground --no-process-group
             ├─1931 /usr/sbin/smbd --foreground --no-process-group
             └─1932 /usr/sbin/smbd --foreground --no-process-group

Warning: some journal files were not opened due to insufficient permissions.

This post is licensed under CC BY 4.0 by the author.

init进程--systemd

sysV init 简要介绍