Skip to content

12. Package Management

Unlike Windows or macOS, where software is often downloaded via web browsers as unmanaged installers, Linux relies on centralized Package Managers to download, install, update, and remove software securely from cryptographically signed repositories.

  • Package: A compressed archive containing pre-compiled binaries, configuration files, and metadata required to install an application.
  • Dependency: Software often relies on shared libraries or auxiliary runtimes. Package managers automatically resolve, download, and install these required dependencies.
  • Repository (Repo): A remote or local server hosting collections of verified packages.
  • Package Ecosystems:
    • Debian / Ubuntu: .deb packages managed by apt and dpkg.
    • RHEL / Rocky / AlmaLinux / Fedora: .rpm packages managed by dnf (and historically yum).

The Debian family uses .deb package archives.

apt (Advanced Package Tool) handles remote repository downloads and automated dependency resolution:

Terminal window
# Update local package metadata cache (Always run before installing!)
sudo apt update
# Upgrade all installed packages to their latest versions
sudo apt upgrade -y
# Install a package
sudo apt install nginx -y
# Remove a package (preserves configuration files)
sudo apt remove nginx
# Purge a package (removes package AND all configuration files)
sudo apt purge nginx
# Search repository packages
apt search "web server"
# Clean local package cache (.deb archives in /var/cache/apt/archives)
sudo apt clean

dpkg installs .deb files directly from disk without resolving remote dependencies:

Terminal window
# Install a local .deb package
sudo dpkg -i custom-app_1.0_amd64.deb
# If installation fails due to missing dependencies, resolve them with APT:
sudo apt install -f
# List all installed packages
dpkg -l
# Search for installed files by package name
dpkg -L nginx

Debian and Ubuntu define repositories in /etc/apt/sources.list and drop-in .list or .sources files inside /etc/apt/sources.list.d/.

12.3 RHEL & Fedora Family: The Evolution from YUM to DNF

Section titled “12.3 RHEL & Fedora Family: The Evolution from YUM to DNF”

YUM (Yellowdog Updater, Modified) was RHEL’s primary package management utility up to RHEL 7. Starting with RHEL 8, YUM was replaced by DNF (Dandified YUM).

DNF offers superior performance, lower memory overhead, and modern features like transactional rollbacks, while retaining backward compatibility by aliasing yum to dnf.

| Feature / Aspect | YUM (RHEL <= 7) | DNF (RHEL >= 8) | |||| | Introduction Year | 2003 | 2013 | | Language | Python 2 | C / C++ and Python 3 | | Dependency Resolver | Custom heuristic algorithm (slower) | Libsolv-based (fast, SAT-solver algorithm) | | Performance & Memory | High memory consumption, slower sync | Lightweight, fast metadata parsing | | Parallel Downloads | Not supported | Supported natively | | Modular Content | Not supported | Supported (Application Streams) | | Transaction Rollback | Not supported | Supported (dnf history undo) | | Transaction History | Basic | Extensive, auditable logs | | Plugin Architecture | Limited Python plugins | Modular C/Python extensions | | Current Status | Deprecated | Default, actively developed | | CLI Compatibility | Native | yum redirects transparently to dnf |

DNF commands are intuitive and match standard administration workflows:

Terminal window
# Install a package
sudo dnf install httpd -y
# Remove a package and its unused dependencies
sudo dnf remove httpd -y
# Update a specific package or upgrade entire operating system
sudo dnf upgrade httpd
sudo dnf upgrade -y
# List available or installed packages
dnf list available
dnf list installed
# Search repositories by keyword or name
dnf search "web server"
# View detailed package metadata
dnf info nginx
# Identify which package provides a specific file or binary (Vital for troubleshooting!)
dnf provides /usr/bin/wget

One of DNF’s greatest superpowers is its transactional integrity. Every package installation, upgrade, or removal is tracked in an auditable database that can be undone:

Terminal window
# View list of past transactions with IDs, actions, and dates
sudo dnf history
# View details of a specific transaction
sudo dnf history info 12
# Roll back / undo a problematic installation or update
sudo dnf history undo 12

RHEL 8+ uses Application Streams to allow administrators to choose between multiple versions of software (e.g., Node.js 18 vs Node.js 20 or PostgreSQL 15 vs 16) without waiting for OS releases:

Terminal window
# List available streams for a module
dnf module list nodejs
# Enable and install a specific version stream
sudo dnf module enable nodejs:20 -y
sudo dnf install nodejs -y
# Switch or reset module streams
sudo dnf module reset nodejs

12.5 Low-Level RPM & Repository Management

Section titled “12.5 Low-Level RPM & Repository Management”

Installs local .rpm packages and verifies disk file integrity against original package checksums:

Terminal window
# Install local .rpm package (-i install, -v verbose, -h hash progress bar)
sudo rpm -ivh custom-agent-2.0.x86_64.rpm
# Query which package owns a specific file
rpm -qf /etc/httpd/conf/httpd.conf
# Verify package integrity (detects altered binaries or permissions)
rpm -V httpd

2. Repository Configuration (/etc/yum.repos.d/)

Section titled “2. Repository Configuration (/etc/yum.repos.d/)”

Both YUM and DNF store repository configurations in /etc/yum.repos.d/*.repo.

Enable or disable repositories dynamically using dnf config-manager:

Terminal window
# Install config-manager plugin if needed (dnf-plugins-core)
sudo dnf install dnf-plugins-core -y
# Enable a repository
sudo dnf config-manager --set-enabled epel
# Disable a repository
sudo dnf config-manager --set-disabled epel-testing
# Add a new custom repository from URL
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

| Platform | Recommended Tool | Key Strengths | Legacy Fallback | ||||| | RHEL 7 / CentOS 7 | yum | Stable, field-proven | Native | | RHEL 8, 9 / Alma / Rocky | dnf | Libsolv, modular streams, rollbacks | yum alias | | Ubuntu / Debian | apt | Broad package availability, PPA support | dpkg |

  1. Audit Repositories: Periodically inspect /etc/apt/sources.list.d/ and /etc/yum.repos.d/ to remove unverified third-party repositories.
  2. Clean Caches Regularly: Run dnf clean all or apt clean on systems with small disk footprints to reclaim gigabytes of cached packages.
  3. Use Transactional Rollbacks: Leverage dnf history undo whenever an update breaks an application rather than manually attempting to reinstall old packages.