Package Management
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
aptwith.debpackages - RHEL/Fedora/Rocky use
dnf(older:yum) with.rpmpackages
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
- Refresh your package index and list how many upgrades are available.
- Search for a CLI tool (e.g.
jq), then install it. - Show metadata for an installed package and note its version and dependencies.
- Remove the package and confirm it is gone with
which.
Cheat Sheet▾
| Action | apt (Debian) | dnf (Fedora) |
|---|---|---|
| Refresh index | apt update | (automatic) |
| Install | apt install pkg | dnf install pkg |
| Upgrade all | apt upgrade | dnf upgrade |
| Remove | apt remove pkg | dnf remove pkg |
| Search | apt search term | dnf search term |
| Info | apt show pkg | dnf 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