Home/Linux Administration/Package Management
📦

Level 6 of 24

Package Management

apt/dpkg on Debian-family systems, dnf/rpm on RHEL-family systems — never treated as identical.

Installing software correctly — with dependencies resolved and updates tracked — is what a package manager does that manually downloading and compiling software doesn't. Debian-family and RHEL-family systems use genuinely different tools, and this level treats them as the two separate systems they are.

Prerequisites

  • • Level 2: Command Line

By the end of this level, you can

  • ✓ Install, update, and remove packages on Debian-family systems with apt
  • ✓ Do the same on RHEL-family systems with dnf
  • ✓ Explain what a repository is and why dependency resolution matters

Debian/Ubuntu package management: apt and dpkg

The .deb format, apt as the modern front-end, and dpkg underneath it. · 9 min

Debian and Ubuntu use the `.deb` package format. `dpkg` is the low-level tool that actually installs, removes, and queries individual `.deb` files, but it does not resolve dependencies or download anything — if a package needs another package that isn't installed, `dpkg` will simply fail. `apt` (and the closely related `apt-get`) is the higher-level tool almost everyone uses day-to-day: it talks to configured repositories, resolves and installs dependencies automatically, and manages the whole lifecycle of installing, updating, and removing software.

The standard workflow: `sudo apt update` refreshes the local list of available packages and their versions from configured repositories (this does not install or upgrade anything by itself — it's purely a metadata refresh, a distinction that surprises people expecting it to update software). `sudo apt upgrade` then actually upgrades installed packages to their latest available versions. `sudo apt install <package>` installs a new package plus its dependencies. `sudo apt remove <package>` uninstalls it but leaves configuration files behind (for a clean full removal including config, use `apt purge`).

Repositories are defined in `/etc/apt/sources.list` and `/etc/apt/sources.list.d/` — these tell `apt` where to fetch package metadata and files from. Adding a third-party repository (a PPA on Ubuntu, or a vendor-provided `.list` file) extends what `apt install` can find beyond the distribution's own default package set, but also means trusting that repository's maintainers and signing key.

CommandPurposeExample
apt updateRefresh the local package index from configured repositories (metadata only, installs nothing)—
apt upgradeUpgrade all installed packages to their latest available version—
apt installInstall a package and its dependenciessudo apt install nginx
apt remove / purgeUninstall a package; purge also removes its configuration filessudo apt purge nginx
apt searchSearch available packages by name/descriptionapt search postgresql
dpkg -lList all currently installed packages (low-level)—
dpkg -i file.debInstall a standalone .deb file directly (no dependency resolution)—

Common Mistakes

  • ⚠ Forgetting `sudo apt update` before `apt install` on a fresh system and getting a "package not found" error for a package that genuinely exists in the repositories
  • ⚠ Confusing `apt update` (refresh metadata) with `apt upgrade` (actually upgrade software) — they do very different things despite similar names
  • ⚠ Using `apt remove` and expecting configuration files to be gone too — that requires `purge`

Takeaway: `apt update` only refreshes what apt knows is available; it never installs or upgrades anything by itself — that surprises almost everyone exactly once before it becomes second nature.

RHEL/Fedora/Rocky package management: dnf and rpm

The .rpm format and dnf as the modern successor to yum. · 8 min

RHEL, Rocky Linux, AlmaLinux, and Fedora use the `.rpm` package format. `rpm` is the low-level tool — like `dpkg`, it installs and queries individual `.rpm` files without resolving dependencies. `dnf` is the modern, high-level package manager (the successor to the older `yum`, which some documentation and older systems may still reference — the commands are largely compatible, and `yum` is often aliased to `dnf` on current systems) that handles repositories and dependency resolution, directly analogous to `apt` on Debian-family systems.

The workflow differs from apt in one meaningful way: `dnf` combines the "refresh metadata" and "install/upgrade" steps more transparently — `sudo dnf install <package>` will automatically refresh repository metadata as needed before installing, and `sudo dnf upgrade` (or the equivalent `update`) refreshes and upgrades in one step, without a mandatory separate "update the index" command that Debian-family workflows train you to run first.

Repository configuration lives in `/etc/yum.repos.d/*.repo` files. Adding a vendor or third-party repository here (with its GPG key imported for signature verification) is the RHEL-family equivalent of adding an APT source — and just like the Debian side, it extends what `dnf install` can find at the cost of trusting that repository's maintainers.

CommandPurposeExample
dnf installInstall a package and its dependencies (refreshes metadata automatically)sudo dnf install nginx
dnf upgradeRefresh and upgrade all installed packages—
dnf removeUninstall a packagesudo dnf remove nginx
dnf searchSearch available packagesdnf search postgresql
dnf list installedList currently installed packages—
rpm -qaList all installed packages (low-level, like dpkg -l)—
rpm -ivh file.rpmInstall a standalone .rpm file directly (no dependency resolution)—

Same task, two package managers

# Debian/Ubuntu
sudo apt update && sudo apt install nginx

# RHEL/Rocky/Alma/Fedora
sudo dnf install nginx

# Different tools, different package formats (.deb vs .rpm) —
# never assume one command works unchanged on the other family.

Quick Check

On a fresh RHEL/Rocky system, you want to install nginx. What is the correct first command?

Takeaway: Package manager, package format, and repository configuration are all different between the Debian and RHEL families — always confirm which family you're on (`cat /etc/os-release`) before running any package command from memory.

Sponsor / Advertisement