{"canonical_url":"https://engineer.company/glossary/systemd/","content_markdown":"# systemd\n\n## What it is\n\nOn nearly every mainstream Linux distribution, process ID 1 is systemd: the\nsystem and service manager that brings the machine up at boot, starts and\nwatches its services while it runs, and takes everything down in order at\nshutdown. The project spells its name in lower case, never SystemD or System D,\nand the trailing d is the old Unix mark of a daemon. It belongs to the family of\ninit systems, alongside the SysV init scripts and Upstart it replaced on most\ndistributions, OpenRC and runit, which some smaller distributions still choose,\nand launchd, which does the same job on macOS.\n\nEverything systemd manages is a unit, described in a short text file of sections\nand key-value pairs. Its manual counts 11 types: service, socket, target,\ndevice, mount, automount, timer, swap, path, slice and scope. A service runs a\nprogram. A timer starts another unit on a schedule. A socket holds a listening\nport and starts its service when the first connection arrives. A target groups\nunits into a state the machine can reach, such as a multi-user system with\nnetworking. Requirements and ordering are separate settings, so \"this needs\nthat\" and \"this starts after that\" are two different lines, and systemd turns\nthem into one transaction of start and stop jobs that it can check before it\nruns.\n\nTwo design choices set it apart from the shell-script init systems before it.\nEach service runs in its own Linux control group, so the manager tracks the\nprocesses in that group and can stop them together, limit their memory\nand account for their CPU. And the project is a suite as well as a manager: its\nown site lists a logging daemon, the journal, along with components for logins,\nnetwork configuration, time synchronisation and name resolution. Distributions\nchoose which of those extras they enable; the manager at PID 1 is the part that\nis close to universal.\n\n## Why it matters\n\nOn a Linux server the question is rarely whether to run systemd, because the\ndistribution already chose it. The real decision is whether to use it as the\nsupervisor and scheduler, or to stack another process manager, a container\ndaemon's restart policy or cron on top of it.\n\nUsing it directly puts start order, restart policy, logs, resource limits and\nsandboxing in one file per service, read by the manager that is already running,\nwithout a second supervisor process. A unit can cap memory with `MemoryMax=`, make the\noperating system's own directories read-only for its service with\n`ProtectSystem=`, and run under a throwaway user with `DynamicUser=`, and\n`systemd-analyze security` scores how exposed each service is on a scale from\n0.0 to 10.0. A job started by a timer, unlike a crontab line, logs to the\njournal, takes the same sandboxing as any service, and shows its last and next\nrun in `systemctl list-timers`. The skill also transfers: an engineer who can\nread a unit file can operate most Linux servers, whichever distribution they\nrun.\n\nThe costs are real too. Units are Linux-only, so a team that also ships to macOS\nwrites launchd property lists, and one that ships to the BSDs writes rc scripts.\nInside most containers there is no systemd at all: the application itself is PID\n1, and a restart policy belongs to whatever runs the container. Where containers\nand plain services share a host, Podman's Quadlet narrows that gap by turning a\ncontainer description into an ordinary service unit, so both kinds of workload\nsit under one supervisor.\n\n## What it looks like in practice\n\nThe company's own platform leans on systemd in three places.\n\nIn the September 2026 implementation record, the production host described in\n[running the company's public services on one 512 MB host](/portfolio/a-whole-company-on-one-small-server/)\nwas a single-core machine with about 464 MB of usable memory. Resident on it were\na web server holding TLS for seven domains, the git forge, the onion service,\none server each for Gemini and Gopher, and intrusion banning. Backup automation\nis implemented separately; that does not establish active encrypted backups.\nAt that size every resident process had to justify its memory, so systemd was\nthe supervisor, with no second supervisor process layered over it, and the\ncontainers ran as Quadlet units under the same manager instead of under a\ncontainer daemon of their own. When the question was whether the host could\nalso carry an onion service, a recorded day of measured samples showed\navailable memory never falling below about 310 MB of 464.\n\nThe\n[backup and restore-test implementation](/portfolio/backups-that-have-actually-been-restored/)\nuses systemd units for a database dump where configured, an encrypted deduplicated restic\nsnapshot to storage at another provider over SFTP, retention pruning and an integrity check.\nA separate monthly workflow restores a known file and compares its bytes, and backup and\nrestore have separate success signals. The timers depend on a configured repository; the\nimplementation record dated 2026-10-27 says they were disabled without one and records no\ncompleted live restore. The work also met one of systemd's sharper edges, described below:\nthe passphrase lives in a protected file the units read, because a value passed through the\nunit's environment has its escapes processed, and a backslash could silently change it.\n\nThe [tech stack](/tech-stack/) draws the general line: plain systemd units by\ndefault, with Docker and Kubernetes kept for the workloads that earn them.\n\n## Where it goes wrong\n\n**An edited unit keeps running with its old settings.** systemd reads unit files\ninto memory, so a change on disk does nothing until `systemctl daemon-reload`\nrebuilds the manager's view, and `systemctl cat` can show a file that differs\nfrom what the running manager uses. Make changes with `systemctl edit`, which\nreloads for you, or reload and then restart the service.\n\n**A secret reaches the service with a character missing.** Values in\n`Environment=` go through systemd's own quoting rules, where C-style escapes are\nprocessed and a literal backslash has to be doubled. systemd's own documentation\nalso warns that environment variables are visible to unprivileged clients over\nD-Bus. Put secrets in a file and pass it with `LoadCredential=`, which hands the\nservice a read-only copy that only its user and root can read.\n\n**A package upgrade quietly undoes a local fix.** Edits made to the vendor's\nfile under `/usr/lib/systemd/system/` are overwritten by the next package\nupdate. Put changes in a drop-in under `/etc/systemd/system/\u003cunit\u003e.d/`, which is\nmerged on top and survives upgrades. Command lists add up rather than replace,\nso a drop-in that changes the start command first clears it with an empty\nassignment:\n\n```ini\n# /etc/systemd/system/app.service.d/override.conf\n[Service]\nExecStart=\nExecStart=/usr/local/bin/app --config /etc/app/app.toml\nRestart=on-failure\n```\n\n**A nightly job skips the night the server was off.** A calendar timer that was\ndue while the machine was down simply waits for its next slot, because\n`Persistent=` defaults to false. Set `Persistent=true` on backups and other jobs\nthat must run, and the missed run fires when the timer is active again, subject\nto any configured random delay.\n\n**A crashed service stays down.** `Restart=` defaults to `no`, so a service that\ndies is left dead until someone notices. Set `Restart=on-failure` for\nlong-running services, and know that once a unit hits its start limit, the\nmanager gives up on it, and a manual start has to wait for the interval to pass\nor for `systemctl reset-failed`.\n\n## Further reading\n\n- [systemd(1)](https://man7.org/linux/man-pages/man1/systemd.1.html) — the\n  manager itself: the unit types, the boot sequence and the signals it answers.\n- [systemd.unit(5)](https://man7.org/linux/man-pages/man5/systemd.unit.5.html)\n  — unit files, dependencies, start limits and the drop-in directories that\n  override them.\n- [systemd.service(5)](https://man7.org/linux/man-pages/man5/systemd.service.5.html)\n  — service types, restart policy and how command lists reset.\n- [systemd.exec(5)](https://man7.org/linux/man-pages/man5/systemd.exec.5.html)\n  — the execution environment, sandboxing options and credentials.\n- [systemd.timer(5)](https://man7.org/linux/man-pages/man5/systemd.timer.5.html)\n  — calendar and monotonic timers, including `Persistent=`.\n- [systemctl(1)](https://man7.org/linux/man-pages/man1/systemctl.1.html) — the\n  command line for starting, editing, reloading and inspecting units.\n\n\u003chttps://engineer.company/glossary/systemd/\u003e\n","date_modified":"2026-11-09T21:50:25Z","description":"How systemd boots a Linux machine and supervises its services, when to use its units and timers instead of cron or a second supervisor, and where it bites.","formats":{"gemtext":"https://engineer.company/glossary/systemd/index.gmi","gopher":"https://engineer.company/glossary/systemd/gophermap","html":"https://engineer.company/glossary/systemd/","json":"https://engineer.company/glossary/systemd/index.json","markdown":"https://engineer.company/glossary/systemd/index.md","pdf":"https://engineer.company/glossary/systemd/index.pdf"},"kind":"page","language":"en","title":"What is systemd?","url":"https://engineer.company/glossary/systemd/","version":1}