Everything that runs in the background on Ubuntu — your web server, database, SSH, cron — is a systemd service, and systemctl is the remote control. Mastering half a dozen subcommands covers 95% of daily server administration. This guide is the practical reference: managing services, enabling them at boot, reading logs, and writing your own unit files.
The daily five
sudo systemctl status nginx # is it running? why did it die? sudo systemctl start nginx # start now sudo systemctl stop nginx # stop now sudo systemctl restart nginx # stop + start (drops connections) sudo systemctl reload nginx # re-read config without dropping connections
status is the first command to run whenever anything misbehaves — it shows whether the service is active, its recent log lines, memory use and the exact command it runs. Prefer reload over restart for config changes when the service supports it (Nginx and Apache do).
Start at boot: enable and disable
sudo systemctl enable nginx # start automatically at boot sudo systemctl enable --now nginx # enable AND start immediately sudo systemctl disable nginx # don't start at boot systemctl is-enabled nginx
Started and enabled are independent: a service can run now but vanish after the next reboot if it was never enabled. After installing anything important, check is-enabled.
Reading service logs with journalctl
journalctl -u nginx -n 50 # last 50 lines for a unit journalctl -u nginx -f # follow live, like tail -f journalctl -u nginx --since "1 hour ago" journalctl -p err -b # every error since boot
Inspecting the whole system
systemctl list-units --type=service --state=running systemctl --failed # anything crashed? systemd-analyze blame | head # what slowed the last boot?
Write your own service unit
Any long-running program — say a Node.js app — deserves a unit file so it restarts on crashes and starts at boot:
sudo nano /etc/systemd/system/myapp.service
[Unit] Description=My Node.js Application After=network.target [Service] Type=simple User=deploy WorkingDirectory=/home/deploy/myapp ExecStart=/usr/bin/node server.js Restart=on-failure RestartSec=5 Environment=NODE_ENV=production [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload sudo systemctl enable --now myapp journalctl -u myapp -f
daemon-reload is required after every edit to a unit file — forgetting it is the classic “why didn't my change apply” moment.
Troubleshooting a service that will not start
Read the error in systemctl status, then the full log with journalctl -u name -n 100. The usual suspects: a port already in use (ss -tlnp shows by whom), wrong file permissions for the service's User=, or a config syntax error — most daemons have a test flag (nginx -t, apachectl configtest, sshd -t).
Related Ubuntu guides
- How to Monitor Ubuntu Server Performance: CPU, RAM and Processes
- How to Install Node.js on Ubuntu 24.04 (APT, NodeSource and NVM)
- How to Install a LEMP Stack (Nginx, MySQL, PHP) on Ubuntu 24.04
- Initial Ubuntu 24.04 Server Setup Guide: Secure Your New VPS in 10 Steps
Prefer to have experts handle it?
LFA IT provides fully managed Ubuntu VPS and dedicated servers — initial setup, security hardening, monitoring and 24/7 support, so you can focus on your business. Explore our hosting and server management services or open a support ticket and our engineers will take it from there.