Package Management

💤0
Lv 10 XP
← 🧱 Foundations · Linux Fundamentals

Package Management

Beginner ⭐ 50 XP ⏱ 15 min #linux#packages#apt#dnf

Install, update, and remove software with your distribution's package manager.

📖Theory

A package manager installs software and automatically resolves its dependencies from configured repositories. The two big families:

  • Debian/Ubuntu use apt with .deb packages
  • RHEL/Fedora/Rocky use dnf (older: yum) with .rpm packages

The universal workflow is the same: update the package index, then install, upgrade, or remove. Always update before installing so you fetch current versions and avoid stale metadata.

🌍Real-World Example
# Debian / Ubuntu
sudo apt update
sudo apt install nginx
sudo apt upgrade
sudo apt remove nginx
apt search keyword
apt show nginx

# Fedora / RHEL
sudo dnf install nginx
sudo dnf upgrade
sudo dnf remove nginx
✍️Hands-On Exercise
  1. Refresh your package index and list how many upgrades are available.
  2. Search for a CLI tool (e.g. jq), then install it.
  3. Show metadata for an installed package and note its version and dependencies.
  4. Remove the package and confirm it is gone with which.
🧾Cheat Sheet
Actionapt (Debian)dnf (Fedora)
Refresh indexapt update(automatic)
Installapt install pkgdnf install pkg
Upgrade allapt upgradednf upgrade
Removeapt remove pkgdnf remove pkg
Searchapt search termdnf search term
Infoapt show pkgdnf info pkg
💬Common Interview Questions
What is the difference between apt update and apt upgrade?

update refreshes the local list of available packages and versions; upgrade downloads and installs the newer versions of installed packages.

What does a package manager do that manual installs don't?

It resolves and installs dependencies, tracks installed files for clean removal, verifies package integrity, and pulls from trusted repositories with updates.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type