Linux 118: Systemd Deep Dive – Managing Services and Boot Processes
Systemd is the modern init system used by most major Linux distributions. It manages everything from service startup to logging, device management, and system states. Understanding systemd is essential for effective system administration.
1. What is systemd?
Systemd is a suite of system components designed to manage:
- System boot and shutdown
- Service supervision
- Device and mount point handling
- Logging via journal
It replaces older init systems like SysVinit and Upstart.
2. systemctl – The Core Command
The systemctl
command is used to interact with systemd.
Start, Stop, Enable Services
Enable/Disable on Boot
Check Status
3. Listing Services and Targets
List All Services
List Enabled Services
Check Target (Runlevel Equivalent)
Change target:
4. Understanding Unit Files
Unit files define how systemd manages resources like services, mounts, devices, and sockets.
Types include:
.service
– services.target
– groups of units.socket
– network sockets.timer
– scheduled tasks
Example unit file: /etc/systemd/system/myapp.service
Enable and start it:
5. Journald – Viewing Logs
Systemd uses journald for centralized logging.
View Recent Logs
Filter by Service
Follow Logs in Real Time
Limit to Boot Session
6. Debugging Boot Issues
Analyze Boot Time
View Boot Processes by Time
Graph Boot Process
Open the file to see a visual representation of boot performance.
7. Scheduling Tasks with systemd Timers
Timers can replace cron for more advanced scheduling.
Create a Timer:
myjob.timer
Create myjob.service
as a companion unit.
Enable and start:
8. Managing System States
Reboot and Shutdown
Suspend and Hibernate
9. Creating Rescue and Emergency Modes
- Rescue mode: Minimal services and root shell
- Emergency mode: Only root filesystem and shell
Enter:
10. Conclusion
Systemd is more than just a service manager — it's the backbone of modern Linux systems. Mastering its components helps you control services, debug boot problems, manage logs, and automate tasks effectively.
Next Steps:
- Learn how to write custom
.service
and.timer
units - Explore
systemd-resolved
andsystemd-networkd
for networking - Practice troubleshooting with
systemd-analyze
andjournalctl
Coming next: Linux 119: Using Containers with Podman and Docker