How Package Management Works
A package manager is a tool that automates the process of installing, updating, configuring, and removing software. It resolves dependencies automatically, ensuring every library and component a program needs is installed correctly. This is one of the features that makes Linux significantly more convenient than manually downloading and installing software.
There are two layers of package management on most Linux systems:
- Low-level tools (dpkg, rpm) — handle installing individual package files directly
- High-level tools (APT, DNF, Pacman) — manage repositories, dependencies, and updates automatically
APT (Debian, Ubuntu, Mint)
APT (Advanced Package Tool) is the standard package manager for Debian-based distributions. It works with .deb packages and is the most widely used package management system in the Linux world.
sudo apt update
# Upgrade all installed packages
sudo apt upgrade -y
# Full upgrade (handles dependency changes)
sudo apt full-upgrade -y
# Install a package
sudo apt install firefox vlc gimp
# Remove a package
sudo apt remove firefox
# Remove package and its configuration files
sudo apt purge firefox
# Search for packages
apt search "text editor"
# Show package information
apt show nginx
# Clean up unused packages and cache
sudo apt autoremove -y
sudo apt clean
sudo apt update before installing or upgrading packages. This refreshes the list of available packages and ensures you get the latest versions.DNF (Fedora, RHEL, AlmaLinux)
DNF (Dandified YUM) is the package manager for Red Hat-based distributions. It works with .rpm packages and provides fast dependency resolution with a modern architecture.
sudo dnf update -y
# Install a package
sudo dnf install nginx
# Remove a package
sudo dnf remove nginx
# Search for packages
dnf search "web server"
# Show package info
dnf info nginx
# List installed packages
dnf list installed
# Clean up cache
sudo dnf clean all
sudo dnf autoremove
Pacman (Arch Linux, Manjaro)
Pacman is the lightning-fast package manager for Arch-based distributions. Its concise syntax and rolling-release model give you access to the very latest software as soon as it is released.
sudo pacman -Syu
# Install a package
sudo pacman -S firefox
# Remove a package and its unused dependencies
sudo pacman -Rns firefox
# Search for a package
pacman -Ss "text editor"
# Show package information
pacman -Si nginx
# List explicitly installed packages
pacman -Qe
# Clean package cache
sudo pacman -Sc
Zypper (openSUSE)
sudo zypper refresh
# Update all packages
sudo zypper update
# Install a package
sudo zypper install nginx
# Search for packages
zypper search "web server"
# Remove a package
sudo zypper remove nginx
Quick Reference Comparison
| Action | APT (Debian/Ubuntu) | DNF (Fedora/RHEL) | Pacman (Arch) |
|---|---|---|---|
| Update index | apt update | dnf check-update | pacman -Sy |
| Upgrade all | apt upgrade | dnf update | pacman -Syu |
| Install | apt install pkg | dnf install pkg | pacman -S pkg |
| Remove | apt remove pkg | dnf remove pkg | pacman -R pkg |
| Search | apt search term | dnf search term | pacman -Ss term |
| Info | apt show pkg | dnf info pkg | pacman -Si pkg |
| Clean cache | apt clean | dnf clean all | pacman -Sc |
Universal Package Formats
Beyond traditional distro-specific packages, universal formats let you install the same package on any Linux distribution regardless of which package manager it uses.
Flatpak
Sandboxed desktop applications distributed through Flathub. Flatpak apps run in isolation with controlled access to system resources, improving security. Each app bundles its own dependencies, so you always get the version the developer tested.
flatpak install flathub org.gimp.GIMP
Snap
Canonical's universal package format, pre-installed on Ubuntu. Snaps auto-update in the background and also run sandboxed. They work across many distributions and are particularly popular for server software and IoT devices.
sudo snap install code --classic
AppImage
Portable, self-contained application files that require no installation. Simply download, make executable, and run. AppImages contain all dependencies within a single file, making them easy to distribute and try without affecting your system.
chmod +x App.AppImage && ./App.AppImage
Nix
A purely functional package manager that provides reproducible builds and atomic upgrades. Nix allows multiple versions of the same package to coexist and makes it possible to roll back any change to your system instantly.
nix-env -iA nixpkgs.firefox
Managing Repositories
Repositories (repos) are servers that host packages for your distribution. You can add third-party repositories to access software not included in the default repositories.
Adding a PPA (Ubuntu)
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-driver-535
Adding a Repository (Fedora)
sudo dnf install \
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
Best Practices
- Update regularly — Run system updates at least weekly to receive security patches and bug fixes
- Use official repositories first — Only add third-party sources when the software is not available in official repos
- Clean up periodically — Remove unused packages and clear the package cache to free disk space
- Read before upgrading — On rolling-release distributions, check for known issues before major updates
- Prefer universal formats for desktop apps — Flatpak and Snap provide sandboxing and independent updates
- Keep a list of installed packages — Useful for recreating your setup on a new machine
dpkg --get-selections > ~/my-packages.txt
# Restore packages on a new system
sudo dpkg --set-selections < ~/my-packages.txt
sudo apt-get dselect-upgrade
Ready to automate with shell scripts?
Shell Scripting Guide →