Learn to write, enable and troubleshoot systemd unit files so services behave predictably during boot and runtime. 16.11.2025 | reading time: 2 min Systemd units are the place where a Linux admin defines how a service starts, stops and integrates with the boot process; this short guide shows concrete commands and a working example so he can manage services reliably. Hands-on: create a minimal service Create a practical demo service by writing a unit file and starting it: ``` sudo tee /etc/systemd/system/mydemo.service > /dev/null <<'UNIT' [Unit] Description=My Demo Service After=network.target [Service] Type=simple ExecStart=/usr/bin/sleep 300 Restart=on-failure [Install] WantedBy=multi-user.target UNIT ``` Then apply and run it: ``` sudo systemctl daemon-reload sudo systemctl enable --now mydemo.service sudo systemctl status mydemo.service --no-pager ``` Inspecting runtime and logs When the service misbehaves, follow these commands to see what happened and why: ``` systemctl status mydemo.service --no-pager journalctl -u mydemo.service -n 50 --no-hostname sudo systemctl show mydemo.service --property=ExecMainPID,LoadState,ActiveState ``` These steps show unit load problems, exit codes and log output so he can iterate quickly. Useful unit options to control behavior Tweak real systems by using options like `Restart=`, `RestartSec=`, `TimeoutSec=`, `User=` and `EnvironmentFile=` in the `[Service]` section, and `WantedBy=` or `RequiredBy=` in `[Install]`; use `ExecStartPre=` for setup commands and `KillMode=` to control shutdown semantics. Complementary tools you will use Beyond editing unit files, rely on `systemctl` to manage units, `journalctl` for logs and `systemd-analyze` to inspect boot sequencing and blame slow units; `systemd-run` is helpful for one-off transient units and testing. Wrap-up and next steps You now have a repeatable workflow: author the unit, reload the daemon, enable or start the unit, and inspect status and logs; practice by converting small daemons and cron jobs into units to see how they integrate with boot and dependencies, and consider formalizing that skill for certification and deeper study at bitsandbytes.academy which prepares for CompTIA Linux+ or LPIC-1. Join Bits & Bytes Academy First class LINUX exam preparation. boot-process processes scripting troubleshooting infrastructure