COMPUTING FOUNDATIONS · GUIDED LESSON

Understand a systemd service

Read a service definition, predict its behaviour and investigate a worked failure using the reference library.

Read the explanation, work through the example and answer the practice questions before taking the knowledge check.

What you will learn

  • Explain ExecStart, WorkingDirectory and Restart.
  • Distinguish restarting a process from reloading unit definitions.
  • Connect status and logs to a diagnosis before changing a service.

What a service manager does

A service manager supervises processes according to unit definitions. A service unit describes how a particular service is started and managed. A service being enabled for an appropriate startup target and a service running now are different states.

This lesson uses a fictional training service. The browser exercise does not execute commands, contact your server or change a system. On a real machine, first check whether systemd is the service manager and which version is installed.

Read the service configuration manual. The hosted library is pinned to v262.2; the installed system may differ.

Read the training unit

[Unit]
Description=HamTron training example

[Service]
Type=simple
WorkingDirectory=/srv/hamtron-demo
ExecStart=/usr/bin/node /srv/hamtron-demo/server.js
Restart=on-failure

The paths are illustrative. WorkingDirectory sets the process working directory. ExecStart names the executable and its arguments. With Type=simple, the specified process is normally the main service process. Restart=on-failure requests restart for qualifying failures, subject to other settings and limits; it is not a guarantee of unlimited restart attempts.

The command is not implicitly run through an interactive shell. A pipe or shell redirection cannot simply be pasted into ExecStart and assumed to behave like a terminal command.

Inspect before changing

These commands illustrate read-only inspection on a system where you are authorised to view the service:

systemctl status hamtron-demo.service --no-pager
systemctl show hamtron-demo.service --property=WorkingDirectory --property=ExecStart
journalctl -u hamtron-demo.service -n 30 --no-pager

The training unit is not installed by this page, so a real machine may report that it is missing. Access to journal messages depends on permissions. status can return a nonzero exit status for an inactive or failed unit; that does not mean inspection itself was an inappropriate action.

Look up systemctl and journalctl in the local library.

Worked example: a missing file

Imagine the service exits with an error saying it cannot find /srv/hamtron-demo/server.js.

  1. Read the effective ExecStart and WorkingDirectory, including any drop-in overrides.
  2. Check whether that exact file exists and is readable by the service account.
  3. Inspect the relevant log entry and its timestamp. Separate an old failure from the current attempt.
  4. Correct the specific path or deployment problem, then verify the intended result.

Changing Restart to always does not supply the missing file. A configured executable path also does not prove that the application is healthy or reachable through a proxy.

Reload definitions versus restart

After a service-unit definition changes, systemctl daemon-reload asks the manager to reread unit configuration. It does not itself restart the application. Restarting a service stops and starts its processes. Reloading an application's own configuration is another operation, supported only when that service implements it.

Changes on a real host require suitable authorisation and may interrupt users. Complete the browser exercise below to practise the distinction without touching a running service.

Use the directives index to explore related settings after the exercise.

BROWSER EXERCISE · FICTIONAL SERVICE

Investigate the evidence

Choose a case, read the observation and decide what it supports. Nothing runs on your computer or server.

Missing application file

Status: failed (exit-code)

Error: Cannot find module '/srv/hamtron-demo/server.js'
Which response fits the evidence?

Read the service reference · Inspect systemctl operations

Practice and explained answers

Work out each answer before expanding it. Use the explanations and worked examples on this page.

A unit is enabled. Must its process be running now?

No. Enablement and runtime state are different. Inspect current status.

Would Restart=always fix an incorrect executable path?

No. Retrying does not correct the path or create the missing file.

You changed ExecStart in a unit file. Does daemon-reload alone run the new command?

No. It reloads unit definitions. Applying the new command to the running service requires an appropriate lifecycle action, commonly a restart.

COMPUTING FOUNDATIONS · STEP 4 OF 13

Check what you learned

Answer both questions correctly to complete this step. You can revise your answers and retry.

1. The journal reports that the ExecStart script is missing. Which next step addresses the evidence?
2. What does daemon-reload do?

Progress stays in this browser. It is not synced to an account or sent as analytics. Passing these introductory checks is not certification.

Editorial credits

Original lesson and exercises prepared for HamTron Learn. Updated 17 November 2026. This is introductory educational material, not a qualification or certification.

Return to Half Echo Learn