Introduction
systemd is the init system and service manager that has become the default on most major Linux distributions including Debian, Ubuntu, Fedora, RHEL, and Arch. It manages the full lifecycle from early boot through service supervision, logging, and shutdown.
What systemd Does
- Starts and supervises system services with dependency-based parallel activation
- Manages the full boot sequence from initrd handoff to multi-user target
- Collects and indexes logs via journald with structured metadata
- Controls resource allocation per service using cgroups (CPU, memory, I/O limits)
- Provides timers, socket activation, device management, and network configuration
Architecture Overview
systemd replaces traditional SysV init with a dependency graph of units. Unit files declare what a service needs and wants, letting systemd parallelize startup. PID 1 (the main systemd process) spawns and monitors services, collecting their output into the journal. Auxiliary daemons handle logging (journald), networking (networkd), DNS resolution (resolved), and time synchronization (timesyncd).
Self-Hosting & Configuration
- Installed by default on most modern Linux distributions
- Place custom unit files in /etc/systemd/system/ to define new services
- Override existing units with
systemctl edit <service>for drop-in configuration - Configure journal retention in /etc/systemd/journald.conf (size and time limits)
- Set resource limits per service with directives like MemoryMax, CPUQuota, and IOWeight
Key Features
- Dependency-based parallel startup reduces boot time significantly
- Socket and D-Bus activation start services on demand rather than at boot
- Structured logging with journald supports filtering by unit, priority, or time range
- Transient services via
systemd-runfor one-off supervised commands - Portable services and systemd-nspawn provide lightweight containerization
Comparison with Similar Tools
- OpenRC — used by Gentoo and Alpine; shell-based, simpler but less feature-rich
- runit — minimalist process supervisor; no journal, no cgroup management
- s6 — supervision suite focused on correctness; steeper learning curve, niche adoption
- launchd — macOS service manager; similar scope but proprietary and Apple-only
FAQ
Q: Why did Linux distributions switch to systemd? A: systemd offers faster parallel boot, unified service management, built-in logging, and cgroup integration that traditional init systems lacked.
Q: Can I still use SysV init scripts? A: Yes. systemd includes a compatibility layer that wraps legacy init scripts as service units.
Q: How do I write a basic service unit?
A: Create a .service file in /etc/systemd/system/ with [Service] ExecStart pointing to your binary, then run systemctl daemon-reload && systemctl start your-service.
Q: Does systemd work in containers? A: It can, but most container images use a simpler init like tini. systemd-nspawn is designed for running full systemd inside lightweight containers.