0Pricing
Linux Server Deployment & SSH Mastery · Lesson

Managing System Services with systemd

Control the long-running programs that power a Linux server using systemd: start, stop, enable, and inspect services, read their logs with journalctl, and understand how units fit into process management.

Managing System Services with systemd is a free Linux Server Deployment & SSH Mastery lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Server Deployment & SSH Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Services vs Ordinary Processes

You have managed individual processes and scheduled tasks. But the programs that define a server — web servers, databases, SSH — run as services: background daemons that should start at boot and restart on failure.

On modern Linux, services are managed by systemd, the system and service manager.

What systemd Manages

systemd organizes everything into units. The most common type is the .service unit, which describes how to run a daemon.

The systemctl command is your main interface to inspect and control these units.

systemctl --version

Checking Service Status

systemctl status shows whether a service is running, its main process ID, recent log lines, and whether it is enabled at boot.

This is usually the first command you run when troubleshooting a service.

systemctl status nginx

Starting and Stopping Services

You control a service's running state with start, stop, and restart. These take effect immediately but do not change boot behavior.

Use reload when a service supports re-reading its config without dropping connections.

sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl stop nginx

Enabling Services at Boot

enable makes a service start automatically when the server boots; disable removes it from boot. This is independent of whether it is running right now.

The handy --now flag both enables and starts in one step.

sudo systemctl enable nginx
sudo systemctl enable --now nginx
sudo systemctl disable nginx

Listing Services

To see what is installed and running, list the unit files or active units.

  • list-units --type=service — currently loaded services
  • list-unit-files --type=service — all installed services and their enabled state
systemctl list-units --type=service --state=running
systemctl list-unit-files --type=service

Reading Logs with journalctl

systemd captures service output in the journal. Query it with journalctl.

  • -u nginx — only this service
  • -f — follow live
  • -e — jump to the end
sudo journalctl -u nginx -f
sudo journalctl -u ssh --since '1 hour ago'

Anatomy of a Unit File

A service is defined by a unit file, usually in /etc/systemd/system/ or /lib/systemd/system/. It has three key sections: [Unit], [Service], and [Install].

The ExecStart line tells systemd what command to run.

[Unit]
Description=My App
After=network.target

[Service]
ExecStart=/usr/bin/myapp --port 8080
Restart=on-failure

[Install]
WantedBy=multi-user.target

Creating Your Own Service

To run your own program as a service, place a unit file in /etc/systemd/system/, reload systemd so it sees the new file, then enable and start it.

daemon-reload is required after any unit file change.

sudo nano /etc/systemd/system/myapp.service
sudo systemctl daemon-reload
sudo systemctl enable --now myapp

Auto-Restart on Failure

One of systemd's best features is automatic recovery. The Restart= directive tells it to relaunch a crashed service.

  • Restart=on-failure — only after a non-zero exit
  • Restart=always — whenever it stops
  • RestartSec=5 — wait before retrying
[Service]
ExecStart=/usr/bin/myapp
Restart=always
RestartSec=5

Best Practices

Manage services confidently:

  • Distinguish runtime (start) from boot (enable)
  • Run daemon-reload after editing unit files
  • Use journalctl -u to debug, not scattered log files
  • Add Restart=on-failure for resilient custom apps

Quick Check

Test your systemd knowledge.

Recap

You can now manage server services with systemd:

  • status, start, stop, restart, reload
  • enable/disable for boot behavior
  • journalctl -u for service logs
  • Custom .service unit files with Restart= for resilience

This rounds out your process and task management skills with long-running daemons.

Frequently asked questions

Is the “Managing System Services with systemd” lesson free?

Yes — the full text of “Managing System Services with systemd” is free to read here on the web, and the Linux Server Deployment & SSH Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Server Deployment & SSH Mastery course, upgrade to CoddyKit PRO.

What will I learn in “Managing System Services with systemd”?

Control the long-running programs that power a Linux server using systemd: start, stop, enable, and inspect services, read their logs with journalctl, and understand how units fit into process manage… You practise Linux Server Deployment & SSH Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Server Deployment & SSH Mastery?

No prior experience is required. Linux Server Deployment & SSH Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Managing System Services with systemd” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Server Deployment & SSH Mastery lesson?

Yes. Every Linux Server Deployment & SSH Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Managing Users and Groups
  2. Monitoring System Processes
  3. Scheduled Tasks with Cron
  4. Managing System Services with systemd
← Back to Linux Server Deployment & SSH Mastery