Package Management
Every command you have learned so far came from somewhere: your distribution installed it, usually through a package manager. Up to this point the book has treated software as simply “there”. This section opens the box: what packages are, how they get installed, and how the major distributions each do it their own way.
A package is a small archive containing a program, its files, and metadata — version number, dependencies (the other packages it needs), and instructions for installing and removing it. A package manager is the tool that installs, updates, queries, and removes those packages while keeping track of what is where. When you run sudo apt install htop, the package manager downloads the htop archive, checks that its dependencies are present, unpacks it, and records what it did — so sudo apt remove htop can undo it cleanly later.
Packages vs. Compiled Programs
Software on Linux arrives in one of two main forms:
- Packages — prebuilt binaries plus metadata, installed by the package manager. Fast to install, easy to update and remove, and safe: the manager knows exactly which files belong to the package.
- Compiled from source — download the code, run
./configure && make && sudo make install. Maximum flexibility (latest version, custom options), but the files land in system directories that no tool tracks, so uninstalling is manual guesswork.
For everyday work, packages win. Compiling is a skill for when a package simply does not exist — and even then, a good distribution probably packages it anyway.
What a Package Manager Does
- Resolves dependencies — if
htopneeds library X and you do not have it, the manager installs X too. - Tracks installed files — a database records every file each package owns, so removal is exact, not forensic.
- Verifies integrity — packages are checksummed (and often signed), so a corrupted or tampered download is rejected.
- Handles upgrades —
apt update && apt upgrade(or the equivalent) moves every installed package to its latest version in one pass.
Common Package Managers
| Manager | Package format | Distributions | Guide |
|---|---|---|---|
apt | .deb | Debian, Ubuntu, and relatives | apt Guide |
dnf / yum | .rpm | Fedora, RHEL, AlmaLinux, Rocky | dnf Guide |
pacman | .pkg.tar.zst | Arch Linux and derivatives | pacman Guide |
snap | snap | Any distro (Ubuntu-first) | snap Guide |
flatpak | flatpak refs | Any distro (desktop apps) | flatpak Guide |
The first three are system package managers: they own the distribution’s software and are the ones you will use most. dnf and yum do the same job on RPM systems — dnf is the modern one, and yum is its older predecessor kept as an alias. Snap and Flatpak are cross-distro package systems: they ship whole applications (with their own bundled dependencies) that install on almost any Linux, which makes them useful for desktop software that updates faster than your distro does.
Repositories
A repository (repo) is a server holding packages and their metadata. Your system’s package configuration lists a few of these by URL; apt update or dnf check-update downloads the lists of what is available, not the packages themselves. Installing then fetches the actual package from the same server.
This is why updating the lists matters: after a new release, the packages exist on the mirror, but your machine does not know until you refresh. “I installed nothing but apt says there are updates” almost always means the local list is stale in the other direction — or that the release notes simply arrived.
Why This Matters
- Every other skill depends on it — installing
htop,curl, or the tools of the Processes section starts here. - Updates are security — a stale package manager means known vulnerabilities stay installed. Weekly
upgradeis a real habit. - Distros differ in syntax only — learn
aptand the others are one--helpaway; the model (repos, dependencies, packages) is identical. - It is the one admin task you cannot avoid — servers, containers, and CI all need software installed, and almost all of it arrives by package manager.
A package manager is a librarian, not a warehouse: it knows which book is on which shelf, which books reference which others, and where every copy came from — so the collection stays tidy while you keep reading.