On almost every modern Linux server, background processes such as web servers, databases and mail services run via systemd. With systemd you manage these services: starting, stopping, restarting, enabling automatic startup, and checking that everything is running smoothly. In this article you’ll learn the most important commands, how to check logs, and how to create your own service, so you can resolve issues yourself without immediately calling your hosting provider.
What is systemd and why is it important
Systemd is the init system that, on most Linux distributions (Ubuntu, Debian, CentOS, AlmaLinux), starts as the first process and then manages all other services. Think of the web server (LiteSpeed or Apache), the database server (MySQL/MariaDB), SSH and cron jobs. Each service runs as a unit, with a configuration file describing how and when the service should start.
The advantage of systemd is that you can manage all services with one consistent set of commands, regardless of which software is behind them. This makes management clear and predictable, whether on your own VPS or on a managed server.
Basic commands for managing services
All systemd commands run through systemctl. Below are the most important commands you need to manage a service, for example nginx, mariadb or sshd.
systemctl status nginxβ shows the current status of the servicesystemctl start nginxβ starts the servicesystemctl stop nginxβ stops the servicesystemctl restart nginxβ fully restarts the servicesystemctl reload nginxβ reloads the configuration without breaking connectionssystemctl enable nginxβ ensures the service starts automatically when the server bootssystemctl disable nginxβ disables automatic startup
Most commands require root privileges, so use sudo before them if you’re not logged in as root.
reload instead of restart for web servers if you’ve only made a configuration change. This prevents downtime for active connections.Viewing logs and troubleshooting
When a service fails to start or stops unexpectedly, systemctl status often already gives a first clue. For more detailed logs, use journalctl, systemd’s central logging service.
journalctl -u nginxβ shows all log lines for the nginx servicejournalctl -u nginx -fβ follows logs live, useful during testingjournalctl -u nginx --since "1 hour ago"β filters by timejournalctl -p errβ shows only error messages from all services
If a service keeps crashing shortly after starting, check whether the configuration is valid (for example with nginx -t for nginx) before restarting the service. If you’re running on a server with Plesk, you can also view many of these statuses graphically via the Plesk panel, including restarting services without a terminal.
Check the status
Run systemctl status [name] to see whether the service is running and whether there are any error messages.
View the logs
Use journalctl -u [name] -f to see in detail what’s going wrong during startup.
Test the configuration
Use the software’s built-in test option (such as nginx -t) to check whether the configuration is valid.
Restart the service
Run systemctl restart [name] and check the status again to confirm everything is running.
Creating your own systemd service
If you’re running your own application or script that always needs to stay active, you can create your own unit file for it. Create a file at /etc/systemd/system/myapp.service with at least the following content:
[Unit]with a description and dependencies (such as network)[Service]with the command to start the application, the restart policy, and optionally the user the process should run as[Install]with the target (usuallymulti-user.target) so the service starts automatically on boot
After creating it, run systemctl daemon-reload so systemd recognizes the new file, and then systemctl enable --now myapp to start the service and enable it to start automatically.
If you’re managing multiple of your own services on a VPS, it’s worth setting a clear restart policy (Restart=on-failure), so the service recovers automatically after a crash. If you’re unsure about the right settings for your web hosting environment, check the knowledge base for more background information.
Frequently Asked Questions
How do I know which services are running?
Use systemctl list-units --type=service --state=running to see all actively running services.
What’s the difference between restart and reload?
Restart fully stops and starts the service again, breaking active connections. Reload only reloads the configuration without stopping the service, which is better for minimal downtime.
Why doesn’t my service start automatically after a reboot?
Check whether the service is enabled with systemctl is-enabled [name]. If it’s disabled, enable it with systemctl enable [name].
Can I also manage systemd services without terminal access?
Yes, on a server with Plesk you can manage many services through the graphical interface, without having to run commands yourself.
Is it safe to restart services myself on my server?
Generally yes, as long as you know which service you’re restarting and what the impact is. If in doubt, you can always contact your hosting provider’s support.
Conclusion
With systemd and the systemctl command, you can easily manage all services on your Linux server: starting, stopping, restarting, and enabling automatic startup. Combine this with journalctl for logs, and you’ll be able to quickly diagnose and resolve many issues yourself. If you still get stuck, our support team is available day and night to help.