Linux Fundamentals, September 2024

How systemd Starts and Supervises Everything

systemd is the first process the Linux kernel starts, process ID 1, and from that position it starts and supervises everything else that runs on the system. It replaced the older init scripts on nearly every major distribution, and while that change drew real objections from engineers who knew the previous system well, systemd is now the layer through which services are defined, started, and kept alive, so understanding it is part of operating Linux rather than optional. What sets it apart from the sequential shell scripts it succeeded is that its model is declarative and dependency driven, it is told what should run and what each thing depends on, and it works out the rest.

The central concept is the unit, a declarative description of something systemd manages, and the most common kind is the service unit, a plain text file that states how to start a program, when to start it, and what it depends on. This is the key departure from the old init scripts, which ran in a fixed sequence one after another. systemd instead reads the declared dependencies of every unit and starts services in parallel wherever their dependencies allow, which is a large part of why modern systems boot faster. A service unit names its dependencies, the conditions under which it should run, and what to do if it fails, and systemd resolves the whole graph rather than following a hand ordered list.

COMMANDWHAT IT DOES
systemctl start, stopStart or stop a service immediately.
systemctl enable, disableSet whether a service starts automatically at boot.
systemctl statusShow whether a service is running, with its recent log lines.
systemctl restart, reloadRestart a service, or reload its configuration without a full restart.
journalctl -u nameShow the collected logs for a specific unit.

systemd also absorbed responsibilities that used to be separate, most visibly logging, through the journal, which collects the output of every service into a single indexed store queried with journalctl rather than scattered across text files under /var/log. This consolidation is exactly what its critics objected to, a single system reaching into many areas that were once independent, and that objection is not unreasonable. But the practical reality for anyone operating Linux today is that systemd is the interface through which services are started, supervised, and inspected, and time spent resisting it is better spent learning it, because a working command of units, dependencies, and journalctl is now simply part of what it means to administer a Linux system competently, whatever one thinks of how it came to be that way.