Services and logs

What a service is

Understand long-running background programs and how systemd represents them as units with dependencies and state.

A service is a program that runs in the background, often starting during boot and waiting for work. A web server waiting for requests, the SSH daemon waiting for logins, a database waiting for queries — all services.

Services exist because a server must do its job with nobody logged in. You cannot keep a terminal open running the web server by hand. Something has to start these programs at boot, restart them when they crash, and keep them running after you disconnect.

systemd and units

Ubuntu uses systemd to manage services and other units. A unit file describes how to start a program, its dependencies, restart behavior, and installation target. A minimal one looks like this:

[Unit]
Description=Notes API

[Service]
ExecStart=/usr/local/bin/notes-api
Restart=on-failure

[Install]
WantedBy=multi-user.target

Read it top to bottom: what this is, what command runs it and what to do when it fails, and when it should start during boot.

Reading a service’s state

Ask systemd about any service:

systemctl status ssh

Two lines in the output carry the state you care about:

Loaded: loaded (/usr/lib/systemd/system/ssh.service; enabled; ...)
Active: active (running) since Mon 2026-08-03 09:14:02 UTC

Do not confuse a running service with an enabled service. Running describes now. Enabled describes whether it should start during boot. The Active: line answers the first question; the word after the unit path in Loaded: answers the second.

The two are independent, and that independence causes a classic failure. You install something, start it, it works — then the server reboots weeks later and the service is down. It was running but never enabled, so nothing brought it back. When a service is mysteriously dead after a reboot, check the Loaded: line first: disabled there is the diagnosis.

The next lessons cover starting, stopping, and enabling services yourself.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →