Manage Services with systemctl

Most Linux systems use systemd to run background services, such as web servers, databases and SSH. systemctl controls the services, and journalctl shows their log messages.

Checking a service

systemctl status apache2
Shows whether the Apache web server is running, plus its latest log lines. Press q to exit.
systemctl list-units --type=service --state=running
Lists every service that is running.
systemctl --failed
Lists services that have failed.

Starting and stopping

sudo systemctl restart apache2
Stops and starts a service. Use start and stop to do just one.
sudo systemctl reload apache2
Reloads the settings without stopping the service, if it supports it.
sudo systemctl enable --now apache2
Starts the service now and every time the computer boots. Use disable to stop it starting at boot.

Reading logs with journalctl

journalctl -u apache2
Shows the log messages for one service.
journalctl -u apache2 -f
Follows the log live, showing new messages as they arrive. Press Ctrl + C to stop.
journalctl --since "1 hour ago"
Shows everything logged in the last hour.
journalctl -b -p err
Shows only errors since the computer last started.

Tip: Add sudo to see log messages from every service.

Quick reference

OptionMeaning
statusIs the service running?
start / stopStart or stop it now
restart / reloadRestart, or reload its settings
enable / disableStart it at boot, or not
--failedList failed services
journalctl -u nameLogs for one service
journalctl -fFollow the log live