Packages and services

Command systemctl

Manage systemd services

Linux · Bash examples · commands run on the selected server

When to use systemctl

Use systemctl to inspect services managed by systemd. Read status and unit configuration before changing state, and distinguish a service being active now from being enabled for future boot.

Syntax

systemctl [PARAMETERS] ACTION [UNIT…]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

status
Show unit status and latest messages.
restart
Stop and restart the service.
enable
Enable startup at boot; --now also starts the service immediately.

Usage examples

Check service

systemctl status nginx

The selected unit's current state and recent status information are shown.

Show running services

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

Loaded service units currently in the running state are listed.

Show the unit configuration

systemctl cat nginx

The unit's configuration and available drop-in fragments are displayed.

Notes and limitations

  • restart can terminate current connections; Before restarting, check the service configuration.
  • systemctl is designed for a system with systemd; in a container without it, the system bus may not be accessible.

Common questions and troubleshooting

Does enabled mean the service is running?

For systemd services, enabled configures startup behavior. The active state describes current runtime activity. Check both properties when diagnosing a service.

Why is systemctl unavailable in a container?

The environment may not run systemd as its service manager. Use the container or host's actual supervision mechanism.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man systemctl.