This article covers How to Manage Services with systemd in detail. Every modern Ubuntu server is run by systemd on Ubuntu acting as the init system and service manager. When your web server fails to start after a reboot, when a database does not come back after maintenance, or when a custom script needs to run as a background daemon, systemd is the tool that decides what happens. Learning how systemd on Ubuntu starts, stops and supervises services is therefore a core sysadmin skill. This guide covers the essential systemctl commands, how to read service logs with journalctl, and how to create your own service unit from scratch.
How systemd on Ubuntu Organizes the System – How to Manage Services with systemd
systemd is PID 1: the first process the kernel starts and the parent of everything else. It organizes work into units. The unit types you will meet most often are .service units (long-running daemons such as Apache, MySQL or SSH), .timer units (scheduled jobs, the modern replacement for many cron tasks), .mount units (filesystems) and .target units (groups of units, similar to old runlevels). Unit files live in three places: /lib/systemd/system for distribution packages, /etc/systemd/system for administrator overrides and your own units, and /run/systemd/system for runtime-generated files. Files in /etc win over files in /lib with the same name.
Prerequisites – How to Manage Services with systemd
- An Ubuntu server (20.04, 22.04 or 24.04) with
sudoprivileges. - Basic command-line experience over SSH.
Core systemctl Commands You Will Use Daily
The systemctl utility is your interface to systemd. Replace apache2 with any service name:
sudo systemctl start apache2 # start a service now
sudo systemctl stop apache2 # stop it
sudo systemctl restart apache2 # stop then start
sudo systemctl reload apache2 # reload config without a full restart
sudo systemctl status apache2 # state, PID and recent log lines
Starting a service is not the same as enabling it. Enable controls whether the service starts automatically at boot:
sudo systemctl enable apache2 # start at boot
sudo systemctl enable --now apache2 # enable AND start immediately
sudo systemctl disable apache2 # do not start at boot
systemctl is-enabled apache2 # check: enabled, disabled or static
Two more useful states: mask links a unit to /dev/null so it cannot be started at all, even manually or as a dependency (sudo systemctl mask apache2), and systemctl list-units --type=service --state=failed shows every failed unit on the system, the first place to look after a bad reboot.

Reading Logs with journalctl
systemd captures service output in the journal. The commands below cover everyday debugging; if the journal grows too large on a small VPS, our guide to clearing the journal log shows how to vacuum it safely.
journalctl -u apache2 # all logs for one unit
journalctl -u apache2 -f # follow new entries live
journalctl -u apache2 --since today # time-filtered view
journalctl -p err -b # errors only, current boot
journalctl --disk-usage # how much space the journal uses
The -b flag limits output to the current boot, and -b -1 shows the previous boot, which is invaluable when a service died during a crash or an unexpected restart.
Creating Your Own Service Unit
Suppose you have a script at /opt/report.sh that must run continuously, restart if it crashes and start at boot. Create a unit file at /etc/systemd/system/report.service:
[Unit]
Description=Daily report generator
After=network.target
[Service]
Type=simple
ExecStart=/opt/report.sh
Restart=on-failure
RestartSec=5
User=www-data
[Install]
WantedBy=multi-user.target
The [Unit] section describes the service and its ordering (After=network.target means start once networking is up). [Service] defines how to run it: ExecStart is the command, Restart=on-failure revives it after a crash, and User avoids running as root. [Install] with WantedBy=multi-user.target is what makes enable work. Load and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now report.service
systemctl status report.service
Always run daemon-reload after editing a unit file; otherwise systemd keeps using the cached version.
Troubleshooting Services with systemd on Ubuntu
Unit not found. Check the exact name with systemctl list-unit-files | grep -i name and confirm the file is in a unit directory.
Service enters a failed state. Read the full error with systemctl status and journalctl -u unit -e, fix the cause, then clear the state with sudo systemctl reset-failed unit.
Service starts before its dependency is ready. Ordering (After=) is not a dependency by itself. Add Wants= or Requires= in [Unit], or use After=network-online.target together with Wants=network-online.target for services that need a fully configured network, such as those you reach over SSH.
Edits have no effect. You forgot daemon-reload, or a drop-in in /etc/systemd/system/unit.d/ is overriding your file. Inspect the effective configuration with systemctl cat unit.
Conclusion
Mastering systemd on Ubuntu turns mystery outages into short checklists: check the status, read the journal, fix the unit, reload the daemon. With systemctl for control, journalctl for visibility and your own unit files for custom workloads, you can supervise anything from a database to a hand-written script with the same reliable workflow. For the complete reference, see the official systemctl documentation from the systemd project.