Chapter 8. Services, Systemd, and Logs

Debian starts almost everything through systemd: the SSH server, the logging daemons, scheduled maintenance, and any application an administrator adds. Everything systemd manages is a unit, described by a small declarative file, and every unit leaves evidence in the journal, the structured log that systemd-journald keeps. This chapter works the two together: what units are and how to read them, how to operate and adapt services, how to filter and control the journal, how file-based application logs are rotated, and how a small network of hosts centralizes its logs on one collector and delivers administrative mail through a relay.

The examples run on Debian 13.5 with systemd 257.13, rsyslog 8.2504.0, logrotate 3.22.0, Postfix 3.10.13, and OpenSSL 3.5.7. Your versions, process IDs, timestamps, and disk figures will differ. Commands entered in john's ordinary shell begin with $, commands entered in a root shell begin with #, a single elevated command is written $ sudo command, and the prompt marker is not typed. John's account and his sudo access were established during installation in Chapter 2; when a procedure says "as root", enter sudo -i from john's shell and leave the root shell with exit. Each console block shows one complete command followed by its own output; where a capture is shortened, the text says what was omitted.

Example files that belong to john live under ~/debian-handbook/services-logs, created the first time it is needed. Unit files, keys, and service configuration belong in the system paths that read them (/etc/systemd/system, /etc/rsyslog-tls, and similar); the chapter creates each of those explicitly. Several sections use more than one machine:

Host Role
client1 Forwarding log client; also the Postfix relay example
client2 Second forwarding log client
collector Central rsyslog collector with two TLS listeners

All three are ordinary Debian systems with john's account. Every command below names its host and shell privilege before it runs.

In this section