Learn how to check running services on Linux, start, stop and restart them, enable them at boot, and read their logs with journalctl using systemctl on any systemd-based distro.
Prerequisites
- A Linux server running a systemd-based distro
- Sudo or root access
- Basic familiarity with the terminal
What this solves
Almost every modern Linux distribution uses systemd to manage background services, from web servers to databases to SSH. This tutorial shows you how to check service status, start and stop services, enable them at boot, list all running or failed services, and read logs with journalctl.
These are the daily commands you will use to confirm something is running, restart it after a config change, or figure out why it crashed.
Step-by-step configuration
Understand systemd and service units
systemd is the init system and service manager used by Ubuntu, Debian, AlmaLinux, Rocky Linux and Fedora. It starts services at boot, restarts them if they crash, and tracks their state through unit files.
Unit files for services usually end in .service and live in /etc/systemd/system/ or /usr/lib/systemd/system/. You interact with all of them through the systemctl command, regardless of which distro you use.
Check the status of a service
The systemctl status command is the first thing to run when you want to know whether a service is active, when it started, and what it has logged recently.
systemctl status sshOn AlmaLinux, Rocky Linux and Fedora the SSH service is usually named sshd instead of ssh.
systemctl status sshsystemctl status sshdThe output shows the load state, the active state (active/running, inactive/dead, or failed), the main process ID, memory usage, and the last few log lines. A green dot means the service is currently running.
Check if a service is active or enabled with short checks
If you just need a quick yes/no answer rather than the full status output, use is-active and is-enabled. These are useful in scripts because they return clean exit codes.
systemctl is-active nginx
systemctl is-enabled nginxThese commands print active/inactive/failed and enabled/disabled respectively, without the extra detail from status.
Start, stop and restart a service
Use start to bring a stopped service up, stop to shut it down cleanly, and restart to stop and start it in one step. Restart is what you want after changing a config file.
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginxIf a service supports it, reload applies configuration changes without dropping active connections, which is safer than a full restart for something like a busy web server.
sudo systemctl reload nginxEnable or disable a service at boot
Starting a service manually only lasts until the next reboot. To make a service start automatically every time the server boots, enable it.
sudo systemctl enable nginxTo start the service immediately and also enable it at boot in one command, use the combined flag.
sudo systemctl enable --now nginxTo prevent a service from starting at boot, disable it. This does not stop a currently running instance, so stop it separately if needed.
sudo systemctl disable nginx
sudo systemctl disable --now nginxList all services on the system
To see every loaded service unit and its current state, list unit files filtered by type.
systemctl list-units --type=service --allTo see only services that are currently running, drop the --all flag.
systemctl list-units --type=serviceTo check which services are set to start on boot versus which are disabled, list the unit files themselves rather than their runtime state.
systemctl list-unit-files --type=serviceFind failed services
When something has crashed or failed to start, systemd marks it as failed. This is the fastest way to spot problems across the whole system after a reboot or deployment.
systemctl --failedIf this list is not empty, investigate each entry with systemctl status and journalctl before moving on. A failed service will not retry on its own unless it has a restart policy configured in its unit file.
Read service logs with journalctl
systemd centralizes logs in the journal, and journalctl is how you read them. This is essential for figuring out why a service failed to start.
sudo journalctl -u nginxTo follow logs live as new entries arrive, similar to tail -f, add the -f flag.
sudo journalctl -u nginx -fTo see only logs since the last boot, which is useful when a service failed right after a restart, combine the unit filter with the boot flag.
sudo journalctl -u nginx -bTo limit output to recent entries, use --since with a relative or absolute time.
sudo journalctl -u nginx --since "1 hour ago"If you manage disk space used by the journal, see optimize systemd journal logging performance and storage for retention and size limits.
Inspect a unit file and reload systemd after changes
If you edit a unit file directly, for example to add environment variables or change the restart policy, systemd will not pick up the change until you reload its configuration cache.
sudo systemctl cat nginx[Service]
Restart=on-failure
RestartSec=5ssudo systemctl daemon-reload
sudo systemctl restart nginxUse systemctl edit nginx instead of editing the vendor unit file directly. It creates an override file in /etc/systemd/system/ that survives package upgrades.
Verify your setup
After starting or enabling a service, confirm both its runtime state and its boot configuration.
systemctl status nginx
systemctl is-enabled nginx
systemctl --failed
sudo journalctl -u nginx -n 50 --no-pagerA healthy service shows active (running), is enabled if it should start at boot, does not appear in the failed list, and has no error-level entries in its recent logs.
Common issues
| Symptom | Cause | Fix |
|---|---|---|
| Service shows failed | Config syntax error or missing dependency | Run sudo journalctl -u servicename -n 50 to read the exact error, then validate the config file |
| Service starts then immediately exits | Application crashes on startup, often from a missing file or bad permissions | Check journalctl -u servicename -f while restarting to catch the crash reason |
| Changes to unit file have no effect | systemd is using a cached version of the unit | Run sudo systemctl daemon-reload then restart the service |
| Service enabled but not running after reboot | It depends on a service or mount that was not ready yet | Add the correct After= and Requires= directives in the unit file |
| Permission denied writing to log or data directory | Service runs as a dedicated user that does not own the directory | Fix ownership with sudo chown -R appuser:appuser /path/to/dir and use 755 or 775 permissions, never chmod 777 |
| systemctl restart hangs | Process is not responding to SIGTERM within the stop timeout | Check for a stuck child process with ps aux | grep servicename and review TimeoutStopSec in the unit |
chown to give the service's actual user access, and keep permissions at 644 for files and 755 for directories unless you have a specific reason to widen them for a shared group.For CPU or memory issues affecting a specific service process, see find out which process is using all your CPU or memory on Linux. If the service won't restart because another process is holding its port, check find and kill processes using a specific port on Linux.
Next steps
- Configure systemd service resource limits and security isolation
- Configure systemd user services for application startup
- Optimize systemd journal logging performance and storage
- Fix systemd service keeps restarting in a loop
- Configure Linux cron jobs and system task scheduling with best practices