Red Hat Training

A Red Hat training course is available for RHEL 8

第 14 章 使用 systemctl 管理系统服务

作为系统管理员,您要管理系统服务并执行与不同服务相关的不同任务,如启动、停止、重启、启用和禁用服务、列出服务以及显示系统服务状态等。要与 systemd 系统和服务管理器交互,请使用 systemctl 实用程序。

14.1. 列出系统服务



  • 要列出所有当前载入的服务单元,请输入:

    $ 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
    abrtd.service            loaded active running ABRT Automated Bug Reporting Tool
    systemd-vconsole-setup.service loaded active exited  Setup Virtual Console
    tog-pegasus.service            loaded active running OpenPegasus CIM Server
    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.
    46 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-units 命令只显示活跃的单位。对于每个服务单元文件,命令会显示:

    • UNIT :其全名
    • LOAD :是否单元文件已被载入的信息
    • ACTIVESUB :它的高级别和低级单元文件激活状态
    • DESCRIPTION: 简短描述
  • 要列出 所有载入的单元,而不管它们的状态 ,请输入以下命令及 --all-a 命令行选项:

    $ systemctl list-units --type service --all
  • 要列出所有可用服务单元的状态(启用的禁用的),请输入:

    $ systemctl list-unit-files --type service
    UNIT FILE                               STATE
    abrt-ccpp.service                       enabled
    abrt-oops.service                       enabled
    abrtd.service                           enabled
    wpa_supplicant.service                  disabled
    ypbind.service                          disabled
    208 unit files listed.


    • UNIT FILE :其全名
    • STATE :是否服务单元已启用或禁用的信息