# systemd systemd is a suite of system and service management components for [[Linux]] operating systems. Created by [[Lennart Poettering]] and [[Kay Sievers]] at Red Hat, it was first released in 2010 and has since become the default init system on most major Linux distributions including Fedora, RHEL, Debian, Ubuntu, [[Arch Linux]], and openSUSE. systemd replaces the traditional SysVinit and provides a unified framework for booting the system, managing services, handling logging, and more. ## Core Components | Component | Purpose | |-----------|---------| | **systemd** (PID 1) | Init system and service manager | | **systemctl** | CLI tool to control services and the system state | | **journald** | Logging daemon that collects and stores log data | | **journalctl** | CLI tool to query the systemd journal | | **logind** | Login and session manager | | **networkd** | Network configuration manager | | **resolved** | DNS resolver | | **timesyncd** | Simple [[Network Time Protocol (NTP)]] client | | **udevd** | Device manager for the Linux kernel | ## Unit Types systemd manages system resources through "units", each defined by a unit file: - **service** — Daemons and processes (e.g., `sshd.service`) - **socket** — IPC, network sockets, or file system FIFOs for socket-based activation - **target** — Groups of units, used to define system states (analogous to runlevels) - **mount** / **automount** — File system mount points - **timer** — Scheduled activation of other units (replacement for cron) - **path** — File system path monitoring - **slice** — Resource management via cgroups - **scope** — Externally created processes ## Common systemctl Commands ```bash # Service management sudo systemctl start <service> sudo systemctl stop <service> sudo systemctl restart <service> sudo systemctl reload <service> # Enable/disable at boot sudo systemctl enable <service> sudo systemctl disable <service> # Check status systemctl status <service> systemctl is-active <service> systemctl is-enabled <service> # List units systemctl list-units systemctl list-units --type=service --state=running systemctl list-unit-files # System state systemctl reboot systemctl poweroff systemctl suspend ``` ## journalctl ```bash # View all logs journalctl # Logs for a specific unit journalctl -u sshd.service # Follow logs in real time journalctl -f # Logs since last boot journalctl -b # Logs from a specific time range journalctl --since "2026-02-06 10:00" --until "2026-02-06 12:00" # Kernel messages only journalctl -k # Show only errors and above journalctl -p err ``` ## Unit File Structure Unit files are typically located in `/etc/systemd/system/` (admin overrides) or `/usr/lib/systemd/system/` (package defaults). ```ini [Unit] Description=My Custom Service After=network.target Wants=network-online.target [Service] Type=simple ExecStart=/usr/bin/myapp Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target ``` After modifying unit files: ```bash sudo systemctl daemon-reload ``` ## Timers systemd timers are the modern replacement for cron jobs: ```ini # /etc/systemd/system/backup.timer [Unit] Description=Daily backup timer [Timer] OnCalendar=daily Persistent=true [Install] WantedBy=timers.target ``` ```bash # List active timers systemctl list-timers ``` ## References - https://systemd.io/ - https://www.freedesktop.org/software/systemd/man/ - https://wiki.archlinux.org/title/Systemd ## Related - [[Lennart Poettering]] - [[Kay Sievers]] - [[Linux]] - [[Arch Linux]] - [[Network Time Protocol (NTP)]] - [[Chrony]] - [[ntpd]]