What Is systemd? Units, Targets, and the Linux Boot Process Explained

Glass orchestration hub connected to server, timer, folder, and socket modules, illustrating systemd units. Linux & Administration
Learn how systemd coordinates Linux startup, what units and targets do, and how to inspect service definitions and dependencies without changing your server.

A server has finished booting, but how did its web server, SSH daemon, scheduled jobs, and mounted filesystems become available? On many Linux distributions, the answer involves systemd: the manager that coordinates much of the system after the kernel starts userspace.

In the previous lesson, Linux services, daemons, and background processes, we separated a managed workload from the program doing the work. This lesson explains the management layer around those workloads.

⚡ Quick Answer

systemd is a system and service manager. Its system instance normally runs as PID 1. It represents managed resources as units, uses dependencies to coordinate them, and groups units through targets. A service is one kind of unit; systemd is not the Linux kernel.

🎯 What You’ll Learn

  • Where systemd fits into startup.
  • How services, sockets, timers, mounts, and targets differ.
  • Why ordering and dependency requirements are separate.
  • How to inspect your own system without changing it.

🐧 Where systemd Fits in Linux

The kernel manages CPU scheduling, memory, devices, and other core operating-system facilities. Userspace programs run on top of that foundation. The initial userspace process has PID 1; on a systemd-based installation, that role is normally handled by systemd.

A simplified startup path looks like this:

Firmware → Boot loader → Kernel / early userspace → systemd → Units

Real startup is more detailed. An initial RAM filesystem may prepare storage before the main root filesystem is used, and some installations use systemd there too. The useful beginner point is that the kernel does not read a list of web servers and start them for you. A userspace manager coordinates those workloads.

Linux does not require systemd. Some distributions use other init systems, and a container may run an application as PID 1. If a command says the system was not booted with systemd, first check the environment rather than assuming the installation is broken.

🧩 What Is a Unit?

A unit is an object systemd knows how to manage. Its suffix tells you what kind of object it is. A unit name is a management identifier, not necessarily the name of an executable.

Unit typeWhat it representsExample use
.serviceA managed workloadA web server or a finite maintenance task
.socketAn activation socketStarting a service when a connection arrives
.timerA time-based triggerActivating a cleanup job on a schedule
.mountA filesystem mountMaking a filesystem available at a path
.targetA grouping and synchronization pointCoordinating a system startup state

A timer usually triggers another unit; it is not the program that performs the scheduled work. Similarly, a socket and the service it activates are separate objects. This is why looking only at running service units does not reveal every activation mechanism.

🚦 Targets Coordinate Groups of Units

A target does not have to launch a permanent process. It expresses a useful grouping in the dependency graph. For example, multi-user.target commonly represents a non-graphical multi-user environment, while graphical.target adds the graphical login environment.

You can ask which target is configured as the default:

systemctl get-default

This reports a configuration choice. It is not an application health check. Reaching a target does not prove that your database accepts queries or your website returns the correct page.

Targets are useful for reading how the machine is organized. Avoid experimenting with target switching on a remote server: stopping units outside a target can interrupt the very session you are using.

🔗 Ordering Is Different from Requiring

Two questions must be answered separately: Should another unit be activated? and Which unit must finish starting first?

  • Wants= pulls another unit into the activation transaction with a relatively weak dependency.
  • Requires= expresses a stronger requirement, with additional failure and stop relationships.
  • After= orders startup when both units are involved; it does not itself request activation of the other unit.

These settings are often combined. An ordering statement alone does not ensure a remote database is ready, and After=network.target does not mean the internet is reachable. Applications still need suitable readiness checks, connection handling, and retries. See the unit configuration reference for exact dependency semantics.

📄 Reading a Service Definition

Inspect a real installed service before trying to write your own. In the following commands, replace example.service with a name found on your machine.

systemctl cat example.service

You may see a main unit file and additional drop-in files. Read all of them: an administrator override can change the behavior described by the packaged file.

Three section names help orient you:

  • [Unit] describes the unit and its relationships.
  • [Service] describes how the service workload is executed and supervised.
  • [Install] describes enablement relationships used when enabling the unit.

For example, ExecStart= identifies a startup command. A setting such as WantedBy=multi-user.target describes how enablement can attach the service to that target. Merely seeing this line in a file does not mean the service has already been enabled.

🧪 Mini Lab: Map a Service to Its Unit

Environment: a Linux system using systemd. These steps inspect state; they do not restart or reconfigure services.

1. Identify the initial process

ps -p 1 -o pid,comm,args

Look at the command associated with PID 1. If this is a container or a different init system, the rest of the lab may not apply.

2. Find installed service definitions

systemctl list-unit-files --type=service

Choose one known service from the output. Names vary: an SSH service may be called ssh.service or sshd.service.

3. Compare definition and current state

systemctl cat example.service
systemctl status example.service --no-pager

The first view explains configuration. The second describes what the manager currently reports. Keep these questions separate: “What is supposed to run?” and “What happened when it ran?”

4. Inspect dependency context

systemctl list-dependencies example.service

Use the tree as a starting point for exploration. It is not a promise of application readiness or a complete account of every external dependency. Press q to leave a pager when one appears.

⚠️ Common Mistakes

“systemd and systemctl are the same thing.” systemd is the manager; systemctl is a command-line client used to talk to it.

“Every unit has a daemon.” Targets group other units, timers trigger work, and some services perform a task and exit.

“An enabled service must be running.” Enablement concerns activation configuration. A service can be enabled and failed, or disabled and running because it was started manually.

“Editing a packaged file is the best customization method.” Package updates can replace vendor files. Learn the drop-in mechanism before making lasting overrides.

✅ Knowledge Check

  1. Why is a target different from a daemon?
  2. Does After= start the named dependency?
  3. Which tool shows a unit file and its drop-ins?
🎓 Check Your Answers

1. A target groups and coordinates units; it need not run a daemon. 2. No: it defines ordering when both units participate. 3. systemctl cat.

Servers Academy — Key Takeaway

Think of systemd as the manager, units as the managed objects, and targets as coordination points. Once you can read those relationships, service behavior becomes easier to investigate.

Continue learning: next, practice managing services with systemctl, then learn to read service logs with journalctl.

Rate article
Add a comment