Chapter 30 — Package management: how software gets onto a Linux box
In one sentence
A package manager installs software along with a formal record of exactly what it depends on, so installing, upgrading, and removing software doesn't silently break something else that quietly relied on the same files.
Why this matters
"Dependency hell" was a real, painful, industry-wide problem before package managers solved it properly — and knowing how your distro's package manager actually works (not just the install command) matters the first time an upgrade goes wrong.
How it actually works
# Debian/Ubuntu family (dpkg underneath, apt as the friendly frontend)
sudo apt update # refresh the list of AVAILABLE packages
sudo apt install nginx # install a package (and its dependencies)
sudo apt remove nginx # remove it (config files may remain)
sudo apt purge nginx # remove it AND its config
apt list --installed | grep nginx # is it installed? which version?
# RHEL/Fedora family (rpm underneath, dnf -- formerly yum -- as the
# friendly frontend)
sudo dnf install nginx
sudo dnf remove nginx
dnf list installed | grep nginx
THE CORE IDEA, either family: a PACKAGE isn't just files -- it's files
PLUS METADATA, including a list of what it DEPENDS ON (other
packages, at specific minimum versions). The package manager reads
this metadata and:
- refuses to install a package if a dependency can't be satisfied
(or, more usefully, AUTOMATICALLY installs the needed
dependencies too)
- refuses to REMOVE a package if something else still depends on it
(without an explicit override)
- tracks exactly what's installed, so it can be queried, upgraded,
or cleanly removed as a unit, rather than "some files that are
probably related to nginx, somewhere."
Real-world example
"Dependency hell" is a real, well-documented, widely-remembered
industry term for the pain that existed BEFORE automatic dependency
resolution was standard: installing one piece of software could
require MANUALLY finding, downloading, and installing several OTHER
pieces of software it depended on, each of which might themselves
need something else, and upgrading ANY of them risked silently
breaking something unrelated that happened to depend on the specific
version you just replaced.
Debian's `dpkg` (and later `apt`, layered on top specifically to
solve automatic dependency resolution) and, separately, the
introduction of `yum` on the RPM side (RPM itself, used by Red Hat
from the mid-1990s, initially had NO automatic dependency
resolution -- installing a package with unmet dependencies simply
FAILED with an error, leaving the user to sort it out manually; `yum`
was created specifically to add automatic resolution on top of RPM,
analogous to what `apt` did for `dpkg`) are both well-documented,
real engineering responses to exactly this problem. This history is
worth knowing because it explains WHY package managers are built the
way they are: the dependency-metadata-and-resolution machinery isn't
bureaucratic overhead, it's the specific, hard-won fix for a genuinely
painful problem the entire industry lived through.
Try it yourself
# Explore what's already installed and why (Debian/Ubuntu example --
# adapt the commands if you're on an RPM-based distro)
apt list --installed 2>/dev/null | wc -l # how much is on this box?
apt-cache depends curl 2>/dev/null | head -10 # what does `curl`
# depend on?
apt-cache rdepends curl 2>/dev/null | head -10 # what DEPENDS ON curl?
# (reverse dependencies --
# this is WHY you can't
# just remove a package
# blindly)
# See a package's actual installed files
dpkg -L curl 2>/dev/null | head -10
Common mistakes
- Force-removing a package with
--forceflags to "fix" a dependency error. This is how you actually END UP in a broken, inconsistent state — understand WHY the dependency conflict exists before overriding it. - Installing software by manually copying files instead of via the package manager. Now the package manager has NO RECORD of it — future upgrades, dependency checks, and clean removal all become manual, error- prone work.
- Not running
apt update(refreshing the package LIST) before installing. You may be attempting to install a version that's no longer available, or missing a newer one, from a stale local index.
Check yourself
- What extra information does a package carry, beyond the actual files?
- Why did "dependency hell" happen before tools like
apt/yumexisted? - What's the difference between
apt removeandapt purge?
Further reading
- Reference:
man 8 apt,man 8 dnf,man 1 dpkg,man 8 rpm. - History: search "dependency hell history package management" for retrospectives on the problem these tools were built to solve.
- Docs: your specific distribution's own package-management documentation (Debian's, Ubuntu's, and Fedora's wikis are all thorough and well maintained).