Linux VPS

Manage Linux services with systemctl and journalctl

Start, stop, restart and enable services with systemctl, and read service logs with journalctl to find out why something failed on your Linux VPS.

BeginnerLinux VPS2 min read

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, apache2 or httpd, mariadb, sshd (ssh on Ubuntu).

Check a service's status

systemctl status nginx

Read 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 nginx

reload 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 nginx

List services

systemctl list-units --type=service --state=running
systemctl --failed

Read logs with journalctl

Show the logs for one service, newest at the end:

sudo journalctl -u nginx
  • -f follows live, like tail -f.
  • -n 100 shows the last 100 lines.
  • --since "1 hour ago" or --since today limits the time.
  • -p err shows errors only.
  • -b this boot only; -b -1 the previous boot, handy after a crash.
sudo journalctl -u mariadb --since "30 min ago" -p err

Keep the journal from filling the disk

journalctl --disk-usage
sudo journalctl --vacuum-size=500M

To 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 (apache2 vs httpd). Search with systemctl 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).

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.