Linux systemctl Command
last modified October 18, 2026
The systemctl command controls the systemd service manager. It is
used to start, stop, enable, and inspect services and other systemd units, as
well as to view their status and logs. This tutorial covers basic and advanced usage of
systemctl with practical examples.
systemctl is available on most modern Linux distributions. It
requires a running systemd instance; minimal containers and some embedded
systems may use another init system.
Check That systemd Is Running
The is-system-running command reports the overall state of the
system manager.
$ systemctl is-system-running running
Common values are running, degraded, and
starting. A degraded state means that at least one unit failed.
Use systemctl --failed to list failed units.
List Running Services
The list-units command shows units that systemd currently knows
about. Filter by type and state to focus on running services.
$ systemctl list-units --type=service --state=running UNIT LOAD ACTIVE SUB DESCRIPTION apache2.service loaded active running The Apache HTTP Server cron.service loaded active running Regular background program processing daemon dbus.service loaded active running D-Bus System Message Bus nginx.service loaded active running A high performance web server
The LOAD, ACTIVE, and SUB columns show
whether the unit definition was loaded and what state it is in. Add
--no-pager when the output is used in a script or a log.
Show the Status of a Service
The status command is the first command to run when a service is
not behaving as expected.
$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2026-10-18 09:12:03 CEST; 2h 14min ago
Docs: man:nginx(8)
Main PID: 812 (nginx)
Tasks: 3 (limit: 18746)
Memory: 8.1M
CPU: 41ms
CGroup: /system.slice/nginx.service
├─812 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─815 nginx: worker process
The output shows whether the unit is loaded, enabled at boot, and active, plus the main PID and the process tree. It also includes the most recent log lines, which often explain why a service failed.
Start, Stop, and Restart a Service
Use start, stop, and restart to change
the current state of a service. These commands usually require root
privileges.
$ sudo systemctl start nginx $ sudo systemctl stop nginx $ sudo systemctl restart nginx $ sudo systemctl reload nginx
restart stops and starts the service. reload asks the
service to reload its application configuration, if supported by the unit.
Support may be implemented through ExecReload= or mechanisms
such as Type=notify-reload. The effect on existing connections
depends on the application. Restarting works for services that cannot reload,
but normally interrupts the service.
Enable a Service at Boot
Starting a service does not make it start automatically at the next boot. The
enable command creates symlinks according to the unit's
[Install] section, commonly adding it to a boot target's
dependencies.
$ sudo systemctl enable nginx Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service. $ sudo systemctl disable nginx Removed /etc/systemd/system/multi-user.target.wants/nginx.service.
Use enable --now to enable a service and start it immediately. The
opposite, disable --now, disables it and stops it in one step.
$ sudo systemctl enable --now nginx
Check Whether a Service Is Active and Enabled
The is-active and is-enabled commands print a short
state and set an exit status that is useful in scripts.
$ systemctl is-active nginx active $ systemctl is-enabled nginx enabled
is-active reports the runtime state, while is-enabled
reports its enablement state. A service can be active but disabled, or enabled
but currently stopped. Disabled services can still be started explicitly or
activated through dependencies, sockets, or timers; enablement alone does not
guarantee a successful start at boot.
List Installed Unit Files
The list-unit-files command shows the unit files installed on the
system and their enablement state.
$ systemctl list-unit-files --type=service UNIT FILE STATE VENDOR PRESET cron.service enabled enabled nginx.service enabled enabled ssh.service disabled enabled
The STATE column can be enabled,
disabled, static, or masked. A
static unit has no enablement instructions in its
[Install] section. It can still be started manually or pulled in
by another unit. A masked unit is deliberately prevented from
starting.
View the Unit File
The cat subcommand prints the unit file and any drop-in overrides
that apply to it.
$ systemctl cat nginx # /lib/systemd/system/nginx.service [Unit] Description=A high performance web server and a reverse proxy server After=network.target [Service] Type=forking ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid TimeoutStopSec=5 KillMode=mixed [Install] WantedBy=multi-user.target
The [Unit] section describes dependencies and ordering. The
[Service] section defines how the process is started and stopped.
The [Install] section specifies the links created when the unit
is enabled, such as links that add it to a target's dependencies.
Override a Unit without Editing It
The edit subcommand creates a drop-in file under
/etc/systemd/system/<unit>.d/. This keeps your changes
separate from the package-provided unit file.
$ sudo systemctl edit nginx
The editor lets you add drop-in settings. For example, you can set the service's open-file descriptor limit:
[Service] LimitNOFILE=65536
After saving, systemctl edit automatically reloads the manager
configuration. Restart the service to apply the new limit to its processes:
$ sudo systemctl restart nginx
When you add or change unit files directly instead of using
systemctl edit, run sudo systemctl daemon-reload
so systemd rereads them. Reloading the manager configuration does not by itself
restart services or reload their application configuration.
View Service Logs
systemctl manages units, while journalctl reads their
logs from the systemd journal.
$ journalctl -u nginx -n 5 Oct 18 09:12:03 webserver systemd[1]: Starting A high performance web server... Oct 18 09:12:03 webserver systemd[1]: Started A high performance web server... Oct 18 09:12:05 webserver nginx[812]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Use journalctl -u nginx -f to follow new entries in real time.
Add --since or --until to restrict the time range,
and -p err to show only errors.
Best Practices for systemctl
- Use status First: Start troubleshooting with
systemctl statusandjournalctl -u. - Reload After Direct Changes: Run
daemon-reloadafter editing or adding unit files directly;systemctl editdoes this automatically. - Use Drop-ins: Override vendor units with
systemctl editinstead of modifying files in/lib/systemd/system. - Enable with --now: Use
enable --nowto enable and start a service in one step. - Check Before Rebooting: Check critical services' enablement with
is-enabledand verify their activation paths and configuration. - Use --user for User Services: Manage per-user units with
systemctl --user.
Source
In this article, we have explored various examples of using the
systemctl command for inspecting services, controlling their
state, enabling them at boot, overriding unit files, and reading logs.
Author
List all Linux tutorials.