What is a Package Manager?
A package manager is a tool that automates the process of installing, upgrading, configuring, and removing software. Instead of downloading executables from websites (as on Windows), Linux users install software from curated repositories — centralized collections of tested, verified packages maintained by the distribution's team.
Package managers handle dependency resolution automatically. If a program requires specific libraries or other packages to function, the package manager downloads and installs everything needed. This eliminates the "dependency hell" problem and ensures software components work together correctly.
APT (Debian, Ubuntu, Mint)
APT (Advanced Package Tool) is the package manager for Debian-based distributions. It works with .deb packages and is the most widely used package manager in the Linux world.
# Update the package index (always do this first)
sudo apt update
# Upgrade all installed packages to latest versions
sudo apt upgrade
# Full upgrade (handles dependency changes, kernel updates)
sudo apt full-upgrade
# Install a package
sudo apt install nginx
# Install multiple packages at once
sudo apt install git curl wget vim
# Remove a package (keep config files)
sudo apt remove nginx
# Remove package and its configuration files
sudo apt purge nginx
# Remove unused dependencies
sudo apt autoremove
# Search for a package
apt search "web server"
# Show package details
apt show nginx
# List installed packages
apt list --installed
# List upgradable packages
apt list --upgradable
# Download a package without installing
apt download nginx
Managing Repositories
# List configured repositories
cat /etc/apt/sources.list
ls /etc/apt/sources.list.d/
# Add a PPA (Ubuntu)
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
# Remove a PPA
sudo add-apt-repository --remove ppa:deadsnakes/ppa
DNF (Fedora, RHEL, Rocky, Alma)
DNF (Dandified YUM) is the package manager for Red Hat-based distributions. It works with .rpm packages and replaced the older YUM tool with better performance and dependency resolution.
# Update package metadata and upgrade all packages
sudo dnf upgrade
# Install a package
sudo dnf install httpd
# Remove a package
sudo dnf remove httpd
# Search for a package
dnf search "text editor"
# Show package info
dnf info httpd
# List installed packages
dnf list installed
# List available updates
dnf check-update
# Install a package group (e.g., Development Tools)
sudo dnf groupinstall "Development Tools"
# Clean cached data
sudo dnf clean all
# View transaction history
dnf history
sudo dnf history undo last
Pacman (Arch, Manjaro, EndeavourOS)
Pacman is the package manager for Arch-based distributions. Known for its speed and simplicity, it uses a concise flag-based syntax.
# Synchronize databases and upgrade all packages
sudo pacman -Syu
# Install a package
sudo pacman -S firefox
# Remove a package and its unused dependencies
sudo pacman -Rs firefox
# Search for a package in repositories
pacman -Ss "text editor"
# Search installed packages
pacman -Qs firefox
# Show package information
pacman -Si firefox # from repos
pacman -Qi firefox # installed
# List all installed packages
pacman -Q
# List explicitly installed packages (not dependencies)
pacman -Qe
# Remove orphaned packages (unused dependencies)
sudo pacman -Rns $(pacman -Qdtq)
# Clean package cache
sudo pacman -Sc
AUR (Arch User Repository)
The AUR is a community-driven repository containing build scripts (PKGBUILDs) for software not in the official repositories. Use an AUR helper like yay or paru for easier installation:
# Install from AUR using yay
yay -S visual-studio-code-bin
# Search AUR
yay -Ss spotify
Package Manager Comparison
| Action | APT (Debian/Ubuntu) | DNF (Fedora/RHEL) | Pacman (Arch) |
|---|---|---|---|
| Update index | apt update | dnf check-update | pacman -Sy |
| Upgrade all | apt upgrade | dnf upgrade | 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 |
| List installed | apt list --installed | dnf list installed | pacman -Q |
| Clean cache | apt autoclean | dnf clean all | pacman -Sc |
Universal Package Formats
Modern Linux also offers distribution-agnostic package formats that work across any distro:
Snap (Canonical)
# Install a snap
sudo snap install vlc
# List installed snaps
snap list
# Update all snaps
sudo snap refresh
# Remove a snap
sudo snap remove vlc
Flatpak (freedesktop.org)
# Install from Flathub
flatpak install flathub org.gimp.GIMP
# Run a flatpak application
flatpak run org.gimp.GIMP
# List installed flatpaks
flatpak list
# Update all flatpaks
flatpak update
# Remove a flatpak
flatpak uninstall org.gimp.GIMP
Compiling from Source
When software is not available in repositories, you can compile it from source code:
# Install build dependencies
sudo apt install build-essential # Debian/Ubuntu
sudo dnf groupinstall "Development Tools" # Fedora
# Typical compilation workflow
tar xzf software-1.0.tar.gz
cd software-1.0
./configure --prefix=/usr/local
make
sudo make install
Best Practice
Always prefer your distribution's package manager over manual installation. Repository packages receive automatic security updates, have tested dependencies, and can be cleanly removed. Use Flatpak or Snap for desktop applications not in your distro's repos. Only compile from source as a last resort.