skip to content

Services and Packages

systemd units and systemctl for running services, journalctl for reading their logs, and apt/dnf/rpm for installing the software in the first place. Interviews ask you to write or debug a unit file far more often than you might expect.

part ofLinux & distributionsoverview, primer and where to startread it →
on this pageshow

questions

11

On a systemd-managed Linux host, what is the difference between `systemctl start nginx` and `systemctl enable nginx`, and what does enabling actually change on disk?

level: juniorimportance: must knowfreq 75%

answer

  1. one acts now, one acts at boot
  2. enable touches disk, not the process table
  3. a symlink into a .wants directory
  4. [Install] decides where the link lands
  5. --now does both in one command

basics

~20 s

start activates a service right now; enable makes it come up automatically at boot. Enabling only creates a symlink so a boot target pulls the unit in — it launches nothing immediately, and starting alone does not survive a reboot.

solid answer

~40 s

They act on two different axes: runtime state versus persistent configuration. `systemctl start nginx` tells the running systemd to activate the unit immediately — it spawns the process and nothing is written to disk, so after a reboot the service comes back only if something else pulls it in. `systemctl enable nginx` writes configuration and activates nothing: systemd reads the unit's `[Install]` section and creates a symlink such as `/etc/systemd/system/multi-user.target.wants/nginx.service` pointing at the unit file. At boot, when systemd activates that target it activates everything linked under it, so the service starts. The classic production bug is a deploy script that only starts services — everything looks healthy until the host reboots and half the stack is missing. `systemctl enable --now nginx` does both, and `systemctl is-enabled nginx` reports which state you are in.

go deeper

for a junior

Know the one-line distinction cold: start is now, enable is at boot, and enable --now does both. Be able to say that a service you only started will be gone after a reboot.

for a middle

Explain the mechanism rather than the slogan: enable reads the unit's install section and drops a symlink into the corresponding target's .wants directory, and boot activates whatever is linked there.

for a senior

Show the operational instinct — treat disabled-but-running as a latent outage, verify enablement in deploy and configuration-management pipelines, and know when masking rather than disabling is the correct guarantee.

for a principal

Frame it as configuration ownership: decide whether boot enablement is declared by packages, by configuration management, or by an image build, and make one of those the single source of truth so hosts cannot drift.

## Two different axes Every service on a systemd host has two independent states: whether it is *running right now*, and whether it is *wired into boot*. `start`/`stop` move the first. `enable`/`disable` move the second. Neither implies the other, and confusing them is the most common operational mistake with systemd. ## What start does `systemctl start nginx.service` sends a request over D-Bus to the running systemd (PID 1) to activate that unit. systemd forks the configured process, places it in a cgroup of its own, and begins supervising it. This is purely an in-memory state change on the running system. Nothing on disk changes. If you reboot, that activation is forgotten unless some persistent rule brings the unit back. ## What enable does `systemctl enable nginx.service` activates nothing at all. It reads the unit's `[Install]` section — a section that exists solely to answer the question "when a human enables me, where should I be hooked in?" — and creates symlinks accordingly. A unit whose install section says `WantedBy=multi-user.target` gets a link created at: ``` /etc/systemd/system/multi-user.target.wants/nginx.service -> /usr/lib/systemd/system/nginx.service ``` That is the entire mechanism. Enablement is not a database flag or a registry entry; it is a symlink in a directory. `disable` deletes the link. ## Why that symlink starts the service at boot At boot systemd activates `default.target`, which on a server usually resolves to `multi-user.target`. When systemd activates a target it also activates every unit linked into that target's `.wants/` and `.requires/` directories. Your symlink is in one of those directories, so the unit gets pulled in. "Enabled" therefore literally means "a link exists in a directory that boot will walk". You can inspect this directly: ```bash ls -l /etc/systemd/system/multi-user.target.wants/ ``` ## The four combinations - **Enabled and running** — the steady state you want in production. - **Enabled but stopped** — it will come back at the next boot. Common right after installing a package and before starting it. - **Disabled but running** — the dangerous one. Everything looks fine on the dashboard; the service silently fails to return after a reboot. - **Disabled and stopped** — inert. Because you almost always want both, systemd offers the combined forms: `systemctl enable --now nginx` enables and starts in one call, `systemctl disable --now nginx` disables and stops. ## What is-enabled actually reports `systemctl is-enabled nginx` does not simply print yes or no. Useful values include: - `enabled` — an install symlink exists. - `disabled` — no install symlink. - `static` — the unit has no `[Install]` section at all, so it *cannot* be enabled. It is meant to be pulled in by other units or activated on demand. - `masked` — the unit name has been symlinked to `/dev/null`. It cannot be started even manually; `start` fails outright. Masking is the strong form of disabling, used when you need to guarantee something never runs. - `indirect` — enablement is expressed through an alias or another unit. The existence of `static` matters for a common misconception: a unit that is not enabled can still run. Socket activation, path activation, or another unit listing it as a dependency will all bring it up without any install symlink. ## The SysV ancestor The split is not a systemd invention. Under SysV init, `service foo start` ran the script now, while `chkconfig foo on` (Red Hat) or `update-rc.d foo defaults` (Debian) created `S`/`K` symlinks under `/etc/rc3.d/` and friends so the script would run at boot. Same separation of concerns, different directory layout — which is why the vocabulary transfers cleanly between the two worlds. ## Interview framing Interviewers ask this because it separates people who have only followed a runbook from people who understand that boot configuration is state on disk. Saying "enable makes it permanent" earns half marks; saying "enable creates a symlink into the target's `.wants` directory, and boot activates whatever is linked there" earns full marks.

  • A colleague says a unit is disabled, yet it is clearly running after boot. What explanations would you check?
    Being disabled only removes the install symlink; it does not prevent activation. The unit may be pulled in as a dependency of another unit, activated on demand through an associated socket or path unit, started by a timer, or started manually by a deploy script or configuration-management run. Check what pulled it in rather than assuming enablement was lost.
  • What does masking a unit do that disabling does not?
    Masking symlinks the unit name to `/dev/null`, which makes the unit unstartable by any route: manual `start` fails, and dependencies of other units cannot pull it in either. Disabling only removes the boot-time install symlink, leaving manual and dependency-driven activation fully available. Masking is what you use when a service must categorically never run.
  • Why do some units report `static` from is-enabled, and can you enable them?
    `static` means the unit file has no `[Install]` section, so there is nowhere for `enable` to place a symlink and the command is refused. Such units are designed to be activated by other units, by a target's dependencies, or on demand. If you truly need one at boot, you add your own drop-in dependency from a unit that does run.

saying these in an interview costs you the question

  • Thinks enable also starts the service immediately
  • Believes start persists across a reboot
  • Treats enable and start as interchangeable aliases
  • Cannot say where the enable symlink is created
  • Assumes a disabled unit can never run

context

open as a page

On a Linux system, what is the difference between the low-level package installer (dpkg on Debian-family systems, rpm on RHEL-family systems) and the higher-level dependency resolver layered on top of it, and why does installing a downloaded .deb or .rpm file directly so often fail?

level: juniorimportance: must knowfreq 65%

basics

~20 s

Low-level tools (dpkg, rpm) install exactly the one file you hand them and merely report unmet dependencies. The resolver above them (apt, dnf, zypper) reads repository metadata, computes a complete transaction, fetches the missing packages, and only then calls the low-level tool.

open as a page

When a package manager plans an install or an upgrade on a Debian- or RPM-based Linux host, what problem is its dependency solver actually solving, and what does it mean when it reports unmet or broken dependencies?

level: middleimportance: must knowfreq 55%

basics

~20 s

The solver searches for a set of package versions that satisfies every declared relationship — requires, conflicts, obsoletes, provides — given what is installed plus everything the enabled repositories offer. Unmet means no such set exists; broken means the local database is already inconsistent.

open as a page

On a systemd host, what is the practical difference between rescue.target and emergency.target, and how do they relate to the old single-user mode?

level: middleimportance: should knowfreq 42%

basics

~20 s

rescue.target is the successor of single-user mode: basic system initialisation and local filesystems are up, with one root shell and no network or multi-user services. emergency.target is far more minimal — essentially just the root filesystem, often read-only, and a shell, used when the system cannot even reach rescue.

open as a page

In systemd, what is a target unit, and why is it not simply a renamed SysV runlevel?

level: middleimportance: should knowfreq 60%

basics

~20 s

A systemd target is a named unit that groups other units and acts as a synchronisation point. Unlike a SysV runlevel, which was a single number with exactly one value active, many targets are active at once and reaching them is dependency-driven, not a numbered sequence.

open as a page

Describe what is physically inside a .deb file and inside an .rpm file: where does each format keep its metadata, its file payload, and its maintainer scripts?

level: middleimportance: should knowfreq 45%

basics

~20 s

A .deb is an ar archive of three members: debian-binary, a control archive holding metadata and maintainer scripts, and a data archive holding the files. An .rpm is a tagged binary header — metadata, file list and scriptlets — followed by a compressed cpio payload.

open as a page

Classic Unix daemons double-forked and wrote a PID file, while a modern service manager supervises the process directly as its own child. What concrete failure modes does the PID-file model have that direct supervision removes?

level: seniorimportance: should knowfreq 48%

basics

~20 s

PID files are self-reported, racy and can go stale: the manager may read the file before it is written, a leftover file can name a recycled PID belonging to an unrelated process, forked children are invisible, and because the manager is not the parent it never learns the exit status. Direct supervision fixes all four.

open as a page

One package on a fleet of Linux servers must stay at a specific version while everything else keeps receiving updates. What do a hold and a version pin actually do on Debian- and RPM-family systems, and what tends to go wrong with them over time?

level: seniorimportance: should knowfreq 38%

basics

~20 s

A hold is a per-package selection state saying "never change this"; a pin is a priority rule steering which candidate version wins. Both silently stop security updates for that package and can block unrelated upgrades once a dependency needs the newer version.

open as a page

How does a Debian- or RPM-based Linux host establish that the packages it installs from a repository are authentic, and what exactly carries the cryptographic signature in each case?

level: seniorimportance: should knowfreq 42%

basics

~20 s

APT signs the repository index: one signature over a file whose hashes chain down to each package, so individual .deb files need no signature. RPM signs each package in its own signature header, and the repository metadata can be signed separately as a second check.

open as a page

You must ship an internal Linux application to machines running several different distributions. How do a traditional distribution package (.deb/.rpm) and a bundled sandboxed format such as Snap or Flatpak differ as delivery models, and how would you decide between them?

level: principalimportance: nice to knowfreq 25%

basics

~20 s

A distribution package links against the host's shared libraries and inherits the distribution's patching and update machinery, but must be built per distribution and release. A bundled format ships its own runtime — one artifact everywhere, plus confinement, at the cost of owning every bundled vulnerability yourself.

open as a page