Modern Linux distributions (Ubuntu, Debian, AlmaLinux, Rocky Linux) run services such as Nginx, MariaDB and SSH under systemd. You control them with systemctl and read their logs with journalctl. Together they answer most "why is my site down" questions.
Before you start
- SSH access as root or a sudo user (see create a sudo user).
- The service name, e.g.
nginx,apache2orhttpd,mariadb,sshd(sshon Ubuntu).
Check a service's status
systemctl status nginxRead the Active: line: active (running) is healthy, failed means it crashed or could not start. The latest log lines appear underneath.
Start, stop, restart and reload
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginxreload re-reads configuration without dropping connections; use it for web servers after config changes, and test the config first (for example sudo nginx -t).
Warning: Restarting sshd with a broken config can lock you out. Run sudo sshd -t first and keep your current session open until a new login works.
Start a service at boot
sudo systemctl enable --now nginx
sudo systemctl disable nginx
systemctl is-enabled nginxList services
systemctl list-units --type=service --state=running
systemctl --failedRead logs with journalctl
Show the logs for one service, newest at the end:
sudo journalctl -u nginx-ffollows live, liketail -f.-n 100shows the last 100 lines.--since "1 hour ago"or--since todaylimits the time.-p errshows errors only.-bthis boot only;-b -1the previous boot, handy after a crash.
sudo journalctl -u mariadb --since "30 min ago" -p errKeep the journal from filling the disk
journalctl --disk-usage
sudo journalctl --vacuum-size=500MTo make the limit permanent, set SystemMaxUse=500M in /etc/systemd/journald.conf and run sudo systemctl restart systemd-journald.
Troubleshooting
- Unit not found: names differ by distro (
apache2vshttpd). Search withsystemctl list-unit-files | grep -i apache. - Address already in use: another program holds the port; see check open ports on Linux.
- Service starts then dies: read
journalctl -u name -n 50. It is usually a config typo, a missing file or wrong permissions (see Linux file permissions).
