Linux systemctl Command: Manage systemd Services

systemctl checks the status of services and other units managed by systemd and controls starting, stopping, restarting, and enabling them at boot. When investigating a service failure, first check the current status with status.

What is the systemctl command?

start is the action to run immediately, and enable is the action to set it to start at boot. They do not automatically replace each other. active and enabled also refer to the current running state and boot setting, respectively. Specify the unit name clearly and check logs with journalctl -u.

Basic syntax

systemctl [option] command [unit]

Installed implementations and options may vary depending on the distribution. Check the description for the current system with man systemctl.

Examples

Checking service status

Replace example unit names with the actual service names on your system.

systemctl status sshd.service

Check if it is currently running

When checking status in a script, also check the exit status.

systemctl is-active sshd.service

Check auto-start settings on boot

See the enable status regardless of current execution.

systemctl is-enabled sshd.service

Distinguishing Service Status and Whether It Is Running

systemctl is-active service_name briefly tells you the current running status. The following service name should be changed according to your environment.

systemctl is-active sshd.service

Example output on a system where the service is running:

active

active means it is currently running. Automatic start on boot is separate, so check it with systemctl is-enabled sshd.service. Service names may vary depending on the distribution, and restart can cause disconnection, so after changing settings, first check the cause with status and journalctl -u.

start starts a service now, whereas enable changes its boot-time activation setting; neither action necessarily performs the other. After editing a unit file, run sudo systemctl daemon-reload to reload its definition, then restart the affected service only when appropriate and inspect its status and logs.

Main Options and Format

Options/Format Description
status unit Displays status and a summary of recent logs.
start / stop unit Starts or stops the unit currently.
restart unit Stops and then starts again, so the connection may be interrupted.
reload unit If the service supports it, it rereads the configuration without restarting.
enable / disable unit Changes the automatic start setting at boot.

Precautions when using

Stopping or restarting remote access services or running web services with stop/restart may interrupt connections and requests. First, check the unit name, change window, and recovery procedure. daemon-reload is the operation that rereads the changed unit definition, not a command to restart the service. It does not apply to systems that are not systemd.

Frequently Asked Questions

If I use systemctl enable, will the service start immediately?

Usually not. enable is a setting for automatic start at boot. To run it now, you need to execute start separately or use the supported --now option.

Official Documentation

You can check the exact behavior of options and differences by implementation in the official documentation related to systemctl.

More in This Category
Linux Directory Structure Explained: Purpose of Major Directories

Linux Directory Structure Explained: Purpose of Major Directories

Understand the purpose of major Linux directories such as /etc, /var, /usr, /home, /proc, and /sys, and learn where common system files belong.

Linux head Command: Display the Beginning of a File

Linux head Command: Display the Beginning of a File

Learn how Linux head prints the first lines or bytes of files and pipelines, labels multiple inputs, excludes a trailing portion, and handles multibyte data.

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Learn what ls, file, stat, and readlink each reveal about a Linux file, including type, size, timestamps, and symbolic-link targets.

Linux cmp Command: Compare Files Byte by Byte

Linux cmp Command: Compare Files Byte by Byte

Learn how Linux cmp compares two files byte by byte, reports the first mismatch, runs silently in scripts, limits ranges, and differs from diff and checksums.

Linux Administration Memo: Essential Commands and System Checks

Linux Administration Memo: Essential Commands and System Checks

A compact Linux administration reference for checking system information, processes, storage, networking, users, permissions, services, and logs.

Linux fdisk Command: Inspect and Edit Disk Partitions

Linux fdisk Command: Inspect and Edit Disk Partitions

Learn how to inspect and Edit Disk Partitions with the Linux fdisk command, including practical examples, key options, and important precautions.

Linux parted Command: Inspect and Manage Partitions

Linux parted Command: Inspect and Manage Partitions

Learn how to inspect and Manage Partitions with the Linux parted command, including practical examples, key options, and important precautions.

Linux systemctl Command: Manage systemd Services

Linux systemctl Command: Manage systemd Services

Learn how to manage systemd Services with the Linux systemctl command, including practical examples, key options, and important precautions.

Linux touch Command: Create Files and Change Timestamps

Linux touch Command: Create Files and Change Timestamps

Learn how to use the Linux touch command to create empty files and change access or modification timestamps, including reference times, date formats, and symlink handling.

Linux umount Command: Unmount a Filesystem Safely

Linux umount Command: Unmount a Filesystem Safely

Learn how to unmount a Filesystem Safely with the Linux umount command, including practical examples, key options, and important precautions.