How to Use systemctl to List and Manage Services on Linux: A Complete Guide for Beginners

目次

1. Introduction

When using Linux, there are many situations where you might want to check the status of services or list all running processes. In such cases, the systemctl command is extremely useful.

This command interfaces with “systemd,” the initialization system and service manager on Linux, providing a wide range of features such as checking service (unit) status, starting, stopping, restarting, and listing services.

Especially when it comes to “listing with systemctl,” you can understand your system’s structure from various angles—not only currently active services, but also inactive ones, or services set to start automatically.

This section will briefly outline the basics of what “systemctl” is, and explain what you will learn in this article.

What is systemctl?

systemctl is the standard tool for controlling and checking various “units” such as services, targets, and mount points on systemd-based Linux distributions.

For example, you use it to start or stop services like Apache (httpd) or SSH, or to list the status of these services.

Relationship Between systemd and systemctl

systemd is the core system for boot processes and service management on Linux, replacing older tools such as SysVinit and Upstart. systemctl is the command-line utility that interacts directly with systemd.

In other words, if systemd is the “controller,” then systemctl acts as the “operator” that sends instructions.

What You Will Learn in This Article

This article answers the following common questions:

  • How can I list all currently running services?
  • How do I include inactive services in the list?
  • How do I check which services are enabled to start automatically?
  • How do I read and interpret the results?

Each command example and its output are carefully explained for beginners, so feel free to follow along to the end.

侍エンジニア塾

2. How to List Services with systemctl

In Linux system administration, quickly grasping the list of services is essential. With the systemctl command, you can easily view not only currently active services but also inactive ones and those configured to start automatically.

Here, we’ll explain three main perspectives for listing services:

  • List of active services
  • List of all services (including inactive ones)
  • List of service unit files (including startup settings)

2.1 Listing Currently Active Services

To check which services are “running” on your system, use this basic command:

systemctl list-units --type=service

This command displays a list of currently active (running) services. The output includes the following columns:

ColumnDescription
UNITName of the service (e.g., ssh.service)
LOADWhether the unit file is loaded
ACTIVEService status (e.g., active, inactive, failed)
SUBDetailed status (e.g., running, exited, dead)
DESCRIPTIONBrief description of the service

This information helps you understand, for example, whether nginx is currently running or what services are active.

2.2 Listing All Services, Including Inactive Ones

By default, list-units only shows currently active services. To include inactive services, add the --all option:

systemctl list-units --type=service --all

This option allows you to see services in the “inactive” state or those that have never been started before.

If you want to narrow down results further, use the --state= option to filter by specific status:

systemctl list-units --type=service --state=inactive

This is useful when you want to check only stopped services, for example.

2.3 Listing Service Unit Files

If you want to know not only the current status but also which services are enabled and set to start automatically, use the following command:

systemctl list-unit-files --type=service

This displays a list of service unit files (configuration files) and lets you check their enable/disable status (enabled, disabled, etc.).

STATE ValueDescription
enabledAutomatically enabled at boot
disabledNot enabled at boot; must be started manually
staticStarted as a dependency of other units; cannot be enabled/disabled directly
maskedExplicitly disabled and cannot be started (protected)

Reviewing this list helps you visually understand which services start at boot and whether any have been accidentally masked.

3. Basic Service Management with systemctl

The systemctl command not only checks service status but also lets you start, stop, restart, and enable or disable services. Here are the basic operations frequently used in Linux system management.

Mastering these commands is essential for daily server management and troubleshooting.

3.1 Starting a Service

To start a specific service manually, use the start subcommand:

sudo systemctl start [service name]

For example, to start Apache (httpd):

sudo systemctl start httpd.service

This starts the service immediately. If you want it to persist after reboot, use enable as well (explained below).

3.2 Stopping a Service

To stop a service, use this command:

sudo systemctl stop [service name]

Example:

sudo systemctl stop sshd.service

The service remains stopped until you explicitly start it again.

3.3 Restarting a Service

To restart a service (for example, after configuration changes), use:

sudo systemctl restart [service name]

Example:

sudo systemctl restart nginx.service

Restart always stops and then starts the service, regardless of its current state.

3.4 Checking Service Status

To check detailed service status, use the status subcommand:

systemctl status [service name]

Example:

systemctl status mysql.service

This shows the current active state, process ID (PID), log summary, and more—very helpful for troubleshooting.

3.5 Enabling a Service to Start Automatically

To ensure a service starts automatically at boot, use the enable subcommand:

sudo systemctl enable [service name]

Example:

sudo systemctl enable docker.service

Now, the service will launch automatically on the next system boot.

3.6 Disabling a Service from Starting Automatically

To disable auto-start, use the disable command:

sudo systemctl disable [service name]

Example:

sudo systemctl disable cups.service

This prevents the service from starting at boot.

3.7 Checking If a Service is Enabled

To check whether a service is enabled (starts automatically), use is-enabled:

systemctl is-enabled [service name]

Example output:

enabled

This quickly tells you the service’s startup policy.

4. Useful Options and Advanced Techniques for systemctl

The systemctl command supports not only basic start/stop operations, but also advanced management tasks. Here are some convenient options and techniques you should know.

Leveraging these features can greatly improve your Linux service management efficiency.

4.1 Listing Service Dependencies

In Linux, some services depend on other units (services, mounts, targets, etc.). To check dependencies, use list-dependencies:

systemctl list-dependencies [service name]

Example:

systemctl list-dependencies nginx.service

This command shows related units in a tree format—helpful for analyzing startup order and indirect dependencies.

4.2 Viewing Unit File Contents

If you want to check the details of a unit’s configuration, you can display the actual unit file:

systemctl cat [service name]

Example:

systemctl cat ssh.service

This shows the file path and its contents, letting you quickly see any custom settings.

4.3 Reloading Unit Files

If you manually modify a unit file, use daemon-reload to apply changes:

sudo systemctl daemon-reexec

Or, more commonly:

sudo systemctl daemon-reload

This reloads unit files in systemd, so changes take effect. If settings don’t seem to apply, try this command first.

4.4 Checking Service Logs (Supplement)

While not a systemctl command itself, journalctl is useful for checking service logs:

journalctl -u [service name]

Example:

journalctl -u docker.service

This lets you review startup errors and restart history—an essential troubleshooting step.

5. Common Problems and Solutions

When managing services with systemctl, things don’t always go as expected. This section explains common issues and how to resolve them.

Be prepared for “service won’t start” or “can’t find the cause” by knowing these basic troubleshooting steps.

5.1 Troubleshooting When a Service Won’t Start

You may see errors like:

Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

To identify the cause, check the following steps in order:

  1. Check status
   systemctl status [service name]
  1. Check error logs
   journalctl -xe
  1. Reload unit files
    If you just edited a unit file, reload with:
   sudo systemctl daemon-reload
  1. Check port conflicts
    See if another process is already using the port:
   sudo netstat -tulnp | grep [port number]

5.2 How to Read Error Messages in the status Command

When you run systemctl status, you see the service’s state as well as the most recent log messages. For example:

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Fri 2025-04-18 12:00:00 JST; 5s ago
  Process: 12345 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)

This lets you quickly spot failures (e.g., “Active: failed”, “status=1/FAILURE”) and which process returned an error.

The Loaded line shows the unit file’s path, making it easy to identify the configuration file to edit.

5.3 When Services Stop Unexpectedly

If a service starts but then stops immediately, common causes include:

  • Errors in configuration files
  • Port conflicts
  • Missing required files or directories
  • Insufficient execution permissions

To resolve, try the following:

  • Check and validate configuration files (e.g., nginx -t or apachectl configtest)
  • Follow detailed logs with journalctl -u [service name]
  • Ensure required directories (e.g., /var/run/xxx) exist; create them if needed

5.4 Unable to Start Services in masked State

If you see this error:

Failed to start example.service: Unit example.service is masked.

The service is in the masked state (completely disabled and blocked from starting). Unmask with:

sudo systemctl unmask [service name]

Then you can start the service as usual.

6. Summary

Service management in Linux is an essential part of daily system operations. The systemctl command plays a central role, enabling you to check lists of services and manage them efficiently.

This article has explained the following points using the “systemctl list” keyword:

What You Can Do with the systemctl Command (Review)

  • Check list of services
  • Display currently active services (list-units --type=service)
  • List all services including inactive ones (--all or --state= options)
  • Show service unit files and their startup status (list-unit-files)
  • Basic service operations
  • Start, stop, restart, and check status (start / stop / restart / status)
  • Enable/disable automatic startup (enable / disable / is-enabled)
  • Advanced operations and troubleshooting
  • Check dependencies, view unit files, reload configurations
  • Investigate errors using logs and status checks

Best Practices for Service Management

  • Always check the status before making changes (status command)
  • Know the auto-start status (is-enabled command)
  • After making changes, always run daemon-reload
  • For issues, check logs with journalctl

Meticulous checks like these ensure stable service delivery and faster troubleshooting in Linux system administration.

For Further Learning

If you’d like to learn more, consider exploring topics such as:

  • systemd targets (and differences from runlevels)
  • Scheduled tasks with systemd-timer
  • How to create and manage custom unit files

7. Frequently Asked Questions (FAQ)

This section summarizes frequently asked questions and answers about the systemctl command and listing services. Even if you’re comfortable with the basics, review these for quick reference.

Q1. What’s the difference between systemctl and service commands?

A1.
systemctl is the systemd-based service management command, and is the standard for most modern Linux distributions (Ubuntu, CentOS, Fedora, etc.).
In contrast, service is from the older SysVinit system. While it’s sometimes kept for compatibility, systemctl is recommended for systemd environments.

Q2. What’s the difference between list-units and list-unit-files?

A2.

  • list-units displays currently loaded units (active or previously used).
  • list-unit-files lists all unit files and their enable/disable status.
    Think of it as the difference between “what’s running now” and “what’s configured to run.”

Q3. Can I start a service in “static” state?

A3.
Yes, you can manually start a service in static state, but you cannot enable it to start automatically. This is because static services are designed to be started as dependencies of other units.

Q4. I can’t start a masked service. What should I do?

A4.
masked means “completely disabled.” Unmask with:

sudo systemctl unmask [service name]

After that, you can start it normally.

Q5. Is there a GUI to list service status?

A5.
Depending on your distribution, tools like gnome-system-monitor, KSysGuard, or Cockpit may let you check service status via a GUI. However, for advanced operations, systemctl remains the most reliable method.

Q6. Where should I place custom unit files?

A6.
Typically, put them in /etc/systemd/system/. After editing, don’t forget to run:

sudo systemctl daemon-reload

Then manage as usual with start or enable.

侍エンジニア塾