Chapter 2. Managing system services with systemctl


To administer system level services, use the systemctl utility. You can interact with systemd by enabling control of services and units. With systemctl, you can manage states of system services, list available services, and display status of system services.

2.1. Listing system services

To optimize system performance, you can use the systemctl command to list and review system services. System services handle background processes, manage hardware, and supports core system functionality.

Prerequisites

  • You have administrative privileges.

Procedure

  • List all currently loaded service units:

    $ systemctl list-units --type service
    Copy to Clipboard Toggle word wrap
    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, or a 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'
    Copy to Clipboard Toggle word wrap

    By default, the systemctl list-units command displays only active units. For each service unit file, the command provides an overview of the following parameters:

    UNIT
    The full name of the service unit
    LOAD
    The load state of the configuration file
    ACTIVE or SUB
    The current high-level and low-level unit file activation state
    DESCRIPTION
    A short description of the unit’s purpose and functionality
  • List all loaded units regardless of their state:

    $ systemctl list-units --type service --all
    Copy to Clipboard Toggle word wrap
  • List the status, for example enabled or disabled, of all available service units:

    $ systemctl list-unit-files --type service
    Copy to Clipboard Toggle word wrap
    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.
    Copy to Clipboard Toggle word wrap

    For each service unit, this command displays:

    • UNIT FILE: The full name of the service unit
    • STATE: The information whether the service unit is enabled or disabled to start automatically during boot

2.2. Displaying system service status

To inspect any service unit to get detailed information and verify the state of the service, use the systemctl command. Status information includes whether the service unit is running, enabled to start during boot, or masked.

You can also view services that are scheduled to start after or before a particular service unit. See the following table for the available service unit information.

Expand
Table 2.1. Available service unit information
FieldDescription

Loaded

Information whether the service unit has been loaded, the absolute path to the unit file, and a note whether the unit is enabled to start during boot.

Active

Information whether the service unit is running followed by a timestamp.

Main PID

The process ID and the name of the corresponding system service.

Status

Additional information about the corresponding system service.

Process

Additional information about related processes.

CGroup

Additional information about related control groups (cgroups).

You can use the following commands to display system service status:

  • Display detailed information about a service unit that corresponds to a system service:

    $ systemctl status <name>.service
    Copy to Clipboard Toggle word wrap

    Replace <name> with the name of the service unit you want to inspect, for example, gdm.

    This command displays the following information:

    • The name of the selected service unit followed by a short description
    • The execution of the service unit, if the unit is executed by the root user
    • The most recent log entries
    • Detailed information about the service unit
  • Verify that a particular service unit is running:

    $ systemctl is-active <name>.service
    Copy to Clipboard Toggle word wrap
  • Decide whether a particular service unit is enabled to start during boot time:

    $ systemctl is-enabled <name>.service
    Copy to Clipboard Toggle word wrap

    Both systemctl is-active and systemctl is-enabled commands return an exit status of 0 if the specified service unit is running or enabled.

  • Check which services systemd scheduled to start before the specified service unit:

    # systemctl list-dependencies --after <name>.service
    Copy to Clipboard Toggle word wrap

    For example, to view the list of services ordered to start before gdm, enter:

    # systemctl list-dependencies --after gdm.service
    Copy to Clipboard Toggle word wrap
    `gdm.service
    ├─dbus.socket
    ├─getty@tty1.service
    ├─livesys.service
    ├─plymouth-quit.service
    ├─system.slice
    ├─systemd-journald.socket
    ├─systemd-user-sessions.service
    └─basic.target
    ...
    Copy to Clipboard Toggle word wrap
  • Check what services systemd orders to start after the specified service unit:

    # systemctl list-dependencies --before <name>.service
    Copy to Clipboard Toggle word wrap

    For example, to view the list of services systemd orders to start after gdm, enter:

    # systemctl list-dependencies --before gdm.service
    Copy to Clipboard Toggle word wrap
    gdm.service
    ├─dracut-shutdown.service
    ├─graphical.target
    │ ├─systemd-readahead-done.service
    │ ├─systemd-readahead-done.timer
    │ └─systemd-update-utmp-runlevel.service
    └─shutdown.target
      ├─systemd-reboot.service
      └─final.target
        └─systemd-reboot.service
    ...
    Copy to Clipboard Toggle word wrap

2.3. Starting and stopping a systemd unit

To start or stop a system service in the current session, you can use the systemctl command.

Prerequisites

  • You have administrative privileges.

Procedure

  • To start or stop a system service:

    # systemctl <action> <systemd_unit>
    Copy to Clipboard Toggle word wrap

    Replace <action> with the action you want to perform to enable or disable the service, for example, start or stop, and replace <systemd_unit> with the service unit name, for example, httpd.

    Note

    Starting a particular service might require starting one or more other services (positive dependency) or stopping one or more services (negative dependency). In systemd, positive and negative dependencies between services exist.

    When you try to start a new service, systemd resolves all dependencies automatically, without explicit notification to the user. This means that if you are already running a service, and you try to start another service with a negative dependency, the first service is automatically stopped.

    For example, if you are running the httpd service (Apache web server) and then try to start the NGINX service, systemd will automatically stop httpd first. This is because both services are web servers that cannot run simultaneously on the same port (usually port 80 or 443).

2.4. Restarting and reloading a system service

To restart or reload a system service in the current session, use the systemctl command. You can use this command to stop the selected service unit and start it again, restart if service is already running, or reload the service without interrupting its execution.

Prerequisites

  • You have administrative privileges.

Procedure

  • Restart a system service:

    # systemctl restart <name>.service
    Copy to Clipboard Toggle word wrap

    Replace <name> with the name of the service unit you want to restart (for example, httpd).

  • Restart a service unit only if the corresponding service is already running:

    # systemctl try-restart <name>.service
    Copy to Clipboard Toggle word wrap
  • Reload the configuration without interrupting service execution:

    # systemctl reload <name>.service
    Copy to Clipboard Toggle word wrap

    Certain services do not support reload operations. If you use systemctl reload-or-restart or systemctl reload-or-try-restart, systemd automatically restarts the service if a reload is not possible. Note that a restart of a service might interrupt connections to this service.

    For details, see systemctl(1) man page on your system.

2.5. Enabling a system service to start at boot

To enable a service to start automatically at boot, you can use the systemctl command. These changes apply with the next reboot.

Prerequisites

  • You have administrative privileges.

Procedure

  • Check if the unit is masked:

    # systemctl status <systemd_unit>
    Copy to Clipboard Toggle word wrap
  • If the unit is masked, unmask it first:

    # systemctl unmask <systemd_unit>
    Copy to Clipboard Toggle word wrap
  • Enable a service to start at boot time:

    # systemctl enable --now <systemd_unit>
    Copy to Clipboard Toggle word wrap

    Replace <systemd_unit> with the name of the service unit you want to enable, for example, httpd.

2.6. Disabling a system service to start at boot

To reduce boot time of your system, you need to either disable or mask the services that start automatically at boot time.

If you disable a service, it will not start at boot, but you can start it manually.

To prevent a service unit from starting automatically or manually, you can mask the service. Masking is a way of disabling a service that makes the service permanently unusable until it is unmasked again.

Prerequisites

  • You have administrative privileges.

Procedure

  • Disable a service to start at boot:

    # systemctl disable <name>.service
    Copy to Clipboard Toggle word wrap

    Replace <name> with the name of the service unit you want to disable (for example, bluetooth). Optionally, pass the --now command to also stop the service if it is currently running.

  • To prevent the unit from being accidentally started by an administrator or as a dependency of other units, mask the service:

    # systemctl mask <name>.service
    Copy to Clipboard Toggle word wrap

    For details, see the systemctl(1) man page on your system.

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る