A server with 40 running services and no idea which ones are actually needed is a security incident waiting to happen. systemctl gives you full visibility and control over every daemon on your system.
How Linux Services Work
Linux services are background processes that run independently of user sessions. They handle everything from web serving to cron scheduling to SSH access. On modern Linux systems, they’re managed by systemd.
What Is a Daemon?
A daemon is a process that runs in the background, typically starting at boot and running continuously. The name comes from Unix tradition. Apache is a daemon. sshd is a daemon. MySQL is a daemon. They don’t have a controlling terminal and don’t require user interaction to run.
systemd vs Older Init Systems
systemd replaced SysVinit as the default init system in most major distributions around 2014-2015. The key differences: systemd starts services in parallel (faster boot), uses declarative unit files instead of shell scripts, tracks service dependencies explicitly, and integrates logging via the journal. If you’re on Ubuntu 16.04+, CentOS 7+, or Debian 8+, you’re using systemd.
How to List Linux Services
List All Unit Files with systemctl
The main command to list services and their states:
sudo systemctl list-unit-files --type=serviceThis outputs every service unit file on the system with its state (enabled, disabled, masked, static, or failed) and its vendor preset default.
List Only Running Services
To see only active services:
sudo systemctl list-units --type=service --state=runningThis is useful when you want to audit what’s actually running versus what’s just installed.
Filter Services by State
systemctl list services supports filtering by state:
sudo systemctl list-units --type=service --state=failedFailed services are the ones you want to investigate immediately. A service that failed on boot and nobody noticed is a common source of mysterious behavior.
Listing Services on Older Systems
On systems still using SysVinit or that have the service command:
service --status-allThe output shows + for running, – for stopped, and ? for unknown state.
How to Manage Linux Services
Start and Stop a Service
Start a stopped service:
sudo systemctl start nginxStop a running service:
sudo systemctl stop nginxThese changes are immediate but not persistent. If the server reboots, the service reverts to its enabled/disabled state.
Restart and Reload a Service
Full restart (stops and starts the process):
sudo systemctl restart nginxReload configuration without restarting the process (supported by some services):
sudo systemctl reload nginxreload is preferable for services like nginx where a restart briefly drops connections. Not all services support it.
Enable and Disable at Boot
Enable a service to start automatically at boot:
sudo systemctl enable nginxDisable it:
sudo systemctl disable nginxEnable and start in one command:
sudo systemctl enable --now nginxCheck a Service Status
View the current state and recent logs for a service:
sudo systemctl status nginxThe output shows whether it’s active or failed, its PID, memory usage, and the last 10 journal lines. It’s the first command to run when a service is behaving unexpectedly.
Reading systemctl Output and Logs
Interpreting Service States
The five states you’ll encounter in list-unit-files output:
- enabled: Service starts at boot via a symlink in /etc/systemd/system/ or similar.
- disabled: Service won’t start at boot but can be started manually.
- masked: Service is hard-disabled. It can’t be started even manually until unmasked.
- static: Service has no install section in its unit file. It only runs when another unit requires it.
- failed: systemd tried to start the service and it exited with an error.
Viewing Logs with journalctl
systemd captures all service output in the journal. View logs for a specific service:
sudo journalctl -u nginxFollow live output:
sudo journalctl -u nginx -fShow only the last 100 lines:
sudo journalctl -u nginx -n 100Linux Service Management Best Practices
- Audit running services periodically. Anything you didn’t install and don’t recognize should be investigated.
- Mask services you never want running, not just disable them. Disabling leaves the door open for packages to re-enable them.
- Use enable –now and disable –now to avoid split-brain states where a service is enabled but not running.
- Check failed services after every reboot: sudo systemctl –failed
- Don’t restart services in production without checking the reload option first. Reloading is less disruptive.
FAQ: Linux List Services
Run: sudo systemctl list-units –type=service –state=running. This shows only currently active services. For all installed services regardless of state, use: sudo systemctl list-unit-files –type=service
Run: sudo systemctl start service-name. Replace service-name with the actual service (e.g., nginx, mysql, sshd). To also enable it at boot: sudo systemctl enable –now service-name
Run: sudo systemctl enable service-name. This creates the necessary symlinks for the service to start automatically on boot. To start it immediately too, add –now: sudo systemctl enable –now service-name
stop halts the service right now but doesn’t change its boot behavior. disable removes the boot symlinks so it won’t start next reboot, but doesn’t affect the currently running instance. To both stop it now and prevent it from starting again, run: sudo systemctl disable –now service-name