# systemd and Daemons

> What a daemon is and how systemd starts, stops and restarts it. How to read a service's log with journalctl when something goes wrong.

**Course:** [Linux Command Line](https://learn.benibix.com/learn/infrastructure-linux)  
**Time:** 12 min

**After this lesson you can:**

- Start, stop and restart a service
- Make a service start at boot
- Read a service's log with journalctl

## How Linux keeps programs running in the background

A daemon is a program that runs in the background all the time, with no window. The web program, the login service and the job timer are all daemons. On almost every Linux system, a program called systemd starts them, watches them and restarts them if they crash. You talk to it with the systemctl command.

systemd is the first program the system starts, so it has the number 1. Every other program hangs below it. Each daemon is described to it as a service, with a name such as nginx or ssh.

Four commands do most of the work. sudo systemctl start nginx starts it. stop stops it. restart stops it and starts it again, which you do after changing its settings. systemctl status nginx shows whether it is running, since when, and its last few log lines.

Starting a service now is not the same as starting it at boot. sudo systemctl enable nginx makes it start each time the machine starts. Forget this, and the service runs fine until the first restart. Then it stays off, and nothing tells you.

Every daemon writes notes about what it is doing. systemd collects them all in one place, called the journal. journalctl reads it. journalctl -u nginx shows only one service. Adding -f keeps the window open and prints new lines as they arrive.

When a service will not start, the reason is nearly always in the journal. It may be a typo in a settings file or a missing file. Or another program may already be using its address. Read the last 20 lines before you change a thing.

A common mistake is to restart a service again and again, hoping it will work. If it failed once, it will fail the same way. Read the journal, fix the cause, and then restart it once.

```console
$ sudo systemctl restart nginx
$ systemctl is-active nginx
active
$ journalctl -u nginx -n 20
```
Restart a service, check that it came back, then read its last 20 log lines.

![systemd at the top, marked process number 1, starts and restarts three daemons below it: nginx, sshd and cron. All three daemons write lines into a journal at the bottom, and journalctl reads them back.](https://learn.benibix.com/diagrams/inf3-services.svg)

### Example: Jack's site is down after a change

Jack edits his web program's settings and restarts it. The site stops loading, and systemctl status says failed.

journalctl -u nginx -n 20 shows the cause on the last line: a missing semicolon on line 14. He adds it, restarts once, and the site is back.

**Words in this lesson:** [Daemon](https://learn.benibix.com/term/infrastructure/daemon), [systemd](https://learn.benibix.com/term/infrastructure/systemd), [journalctl](https://learn.benibix.com/term/infrastructure/journalctl)

**Question:** A service runs now, but stops after every reboot. What was missed?

**Answer:** sudo systemctl enable. start only runs it now. enable tells systemd to start it each time the machine starts.

---

Source: https://learn.benibix.com/learn/infrastructure-linux/systemd-and-daemons
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
