Quick take: The systemctl command controls systemd services. Use systemctl status name to check a service, start/stop/restart to control it, and enable to start it automatically at boot. Most actions need sudo.
Introduction
The systemctl command is the control centre for systemd, the init system on nearly every modern Linux distribution. It starts and stops services, enables them to run at boot, shows their status and logs, and reloads their configuration — making it essential for managing web servers, databases, and any background service.
This guide covers the core service actions, enabling services at boot, checking status, and reloading configuration safely.
Syntax
The basic syntax of the systemctl command is:
systemctl [COMMAND] [SERVICE]Common Options and Parameters
The most useful options and parameters for the systemctl command:
| Option | Description |
|---|---|
| status SERVICE | Show whether a service is running, plus recent log lines. |
| start SERVICE | Start a service now. |
| stop SERVICE | Stop a running service. |
| restart SERVICE | Restart a service (stop then start). |
| reload SERVICE | Reload configuration without a full restart. |
| enable SERVICE | Start the service automatically at boot. |
| disable SERVICE | Do not start the service at boot. |
| is-active SERVICE | Print whether the service is currently running. |
| list-units --type=service | List loaded services. |
| daemon-reload | Reload systemd after editing unit files. |
Practical Examples
Real systemctl commands you can run today:
# Check a service's status
systemctl status nginx
# Start and stop a service
sudo systemctl start nginx
# Restart after a config change
sudo systemctl restart nginx
# Reload without dropping connections
sudo systemctl reload nginx
# Enable a service to start at boot
sudo systemctl enable nginx
# Enable and start in one step
sudo systemctl enable --now nginx
# List all running services
systemctl list-units --type=service --state=runningCreating Your Own systemd Service
One of systemd's most useful features is how easily you can turn any script or program into a managed service that starts at boot and restarts on failure. You write a small unit file:
# /etc/systemd/system/myapp.service
[Unit]
Description=My App
After=network.target
[Service]
ExecStart=/usr/bin/node /srv/myapp/server.js
Restart=on-failure
User=myapp
[Install]
WantedBy=multi-user.targetThen reload systemd and enable it: sudo systemctl daemon-reload followed by sudo systemctl enable --now myapp. Your program now gets automatic startup, restart-on-crash, and centralised logging through journalctl — for free.
Inspecting Failed Services
When a service will not start, systemctl and journalctl together tell you why. Start with systemctl status name, which shows the current state and the last few log lines, then dig deeper with the journal.
# List everything that failed to start
systemctl --failed
# Full logs for one service since the last boot
journalctl -u myapp -b --no-pager
# Why did it exit? Check the result and exit code
systemctl status myappThe --failed view is a fast health check for a whole machine, and pairing it with journalctl -u turns a vague “it won't start” into a specific error you can fix.
Tips and Best Practices
enable --nowstarts a service immediately and enables it at boot in a single command.- Prefer
reloadoverrestartwhen a service supports it — it applies config changes without dropping active connections. - After editing a unit file, run
sudo systemctl daemon-reloadso systemd picks up the changes before you restart the service.
Final Thoughts
systemctl is the single command for managing services on modern Linux. Learn status, start/stop/restart, reload, and enable, and you can control any service and ensure it survives a reboot. Pair it with journalctl to read a service's logs when something goes wrong.
FAQ: systemctl Command in Linux
How do I start and stop a service in Linux?+
Use sudo systemctl start servicename to start and sudo systemctl stop servicename to stop. Use restart to do both in sequence after a configuration change.
How do I make a service start at boot?+
Run sudo systemctl enable servicename. To enable and start it at once, use sudo systemctl enable --now servicename. Use disable to stop it starting at boot.
How do I check if a service is running?+
Use systemctl status servicename for full details, or systemctl is-active servicename for a one-word answer (active or inactive).
What is the difference between restart and reload?+
restart stops and starts the service, briefly interrupting it. reload re-reads the configuration without a full restart, so active connections are preserved — but only services that support it can reload.
Why do I need daemon-reload?+
After you create or edit a systemd unit file, systemd does not see the change until you run sudo systemctl daemon-reload. Do that before restarting the service.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support