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 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 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 killall Command: Signal Processes by Name

Linux killall Command: Signal Processes by Name

Learn how to signal Processes by Name with the Linux killall command, including practical examples, key options, and important precautions.

Linux lsblk Command: Inspect Disks, Partitions, and Mounts

Linux lsblk Command: Inspect Disks, Partitions, and Mounts

Learn how to inspect Disks, Partitions, and Mounts with the Linux lsblk command, including practical examples, key options, and important precautions.

Linux blkid Command: Find Block-Device UUIDs and Filesystem Types

Linux blkid Command: Find Block-Device UUIDs and Filesystem Types

Learn how to find Block-Device UUIDs and Filesystem Types with the Linux blkid command, including practical examples, key options, and important precautions.

Linux nslookup Command: Query DNS Names and Records

Linux nslookup Command: Query DNS Names and Records

Learn how to query DNS Names and Records with the Linux nslookup command, including practical examples, key options, and important precautions.

Linux jobs Command: List Jobs in the Current Shell

Linux jobs Command: List Jobs in the Current Shell

Learn how to list Jobs in the Current Shell with the Linux jobs command, including practical examples, key options, and important precautions.

Linux uptime Command: Check Uptime and Load Averages

Linux uptime Command: Check Uptime and Load Averages

Learn how to use the Linux uptime command to check how long the system has been running and interpret load averages, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux unxz Command: Decompress xz Files

Linux unxz Command: Decompress xz Files

Learn how to decompress xz Files with the Linux unxz command, including practical examples, key options, and important precautions.

Linux gunzip Command: Decompress gzip Files

Linux gunzip Command: Decompress gzip Files

Learn how to decompress gzip Files with the Linux gunzip command, including practical examples, key options, and important precautions.