🐧 Linux / Shell Scripting
Advanced
What is systemd and how do you use it?
Answer
systemd is the init system and service manager used by most modern Linux distros. It replaces SysV init and uses unit files (in /etc/systemd/system/ or /lib/systemd/system/) to define services, mounts, timers, sockets, and more. Key commands: systemctl start/stop/restart/reload servicename, systemctl enable/disable servicename (enable = start at boot), systemctl status servicename, systemctl list-units --type=service. Logs: journalctl -u servicename -f (follow), journalctl -b (since last boot), journalctl --since "1 hour ago". Create a service unit file with [Unit], [Service], and [Install] sections. Run systemctl daemon-reload after changing unit files.