Package Managers Reference
Quick Lookup Table
| Task | RHEL/Fedora (dnf) | Arch (pacman) | Debian/Ubuntu (apt) |
|---|---|---|---|
Install |
|
|
|
Remove |
|
|
|
Remove + deps |
|
|
|
Remove + config |
|
|
|
Update repos |
|
|
|
Upgrade all |
|
|
|
Full upgrade |
|
|
|
Search |
|
|
|
Info |
|
|
|
List installed |
|
|
|
List files |
|
|
|
Find owner |
|
|
|
Clean cache |
|
|
|
List repos |
|
|
|
Download only |
|
|
|
DNF (RHEL/Fedora)
Installation
# Single package
sudo dnf install nginx
# Multiple packages
sudo dnf install nginx php-fpm mariadb
# Specific version
sudo dnf install nginx-1.24.0
# From local RPM
sudo dnf install ./package.rpm
# Group install
sudo dnf groupinstall "Development Tools"
Removal
# Remove package
sudo dnf remove nginx
# Remove with unused dependencies
sudo dnf autoremove
# Remove specific with autoremove
sudo dnf remove nginx && sudo dnf autoremove
Updates
# Check for updates
dnf check-update
# Upgrade all packages
sudo dnf upgrade
# Upgrade specific package
sudo dnf upgrade nginx
# Security updates only (RHEL/CentOS)
sudo dnf upgrade --security
# Rollback transaction
sudo dnf history
sudo dnf history undo 15
Search & Info
# Search by name
dnf search nginx
# Search in descriptions
dnf search all nginx
# Package info
dnf info nginx
# List available versions
dnf list nginx --showduplicates
# List installed packages
dnf list installed
dnf list installed "python3*"
# Provides (what package has this file)
dnf provides /usr/bin/python3
Repositories
# List repos
dnf repolist
dnf repolist all
# Enable/disable repo
sudo dnf config-manager --enable repo-name
sudo dnf config-manager --disable repo-name
# Add repo
sudo dnf config-manager --add-repo https://example.com/repo.repo
# Enable EPEL (RHEL/Rocky/Alma)
sudo dnf install epel-release
# Enable RPM Fusion (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
Pacman (Arch Linux)
Installation
# Single package
sudo pacman -S nginx
# Multiple packages
sudo pacman -S nginx php-fpm mariadb
# Sync repos and install
sudo pacman -Sy nginx
# Install from local file
sudo pacman -U ./package.pkg.tar.zst
# Answer yes to all
sudo pacman -S --noconfirm nginx
Removal
# Remove package only
sudo pacman -R nginx
# Remove with dependencies
sudo pacman -Rs nginx
# Remove with deps and config
sudo pacman -Rns nginx
# Remove orphaned packages
sudo pacman -Rns $(pacman -Qdtq)
Updates
# Full system upgrade (ALWAYS use this)
sudo pacman -Syu
# Force database refresh
sudo pacman -Syyu
# Download only
sudo pacman -Syuw
Never run pacman -Sy package (partial upgrade). Always use -Syu.
|
Search & Info
# Search repos
pacman -Ss nginx
# Search installed
pacman -Qs nginx
# Package info (repos)
pacman -Si nginx
# Package info (installed)
pacman -Qi nginx
# List files in package
pacman -Ql nginx
# Find package owning file
pacman -Qo /usr/bin/nginx
# List explicitly installed
pacman -Qe
# List orphans
pacman -Qdt
Cache Management
# Clean old packages (keep 3 versions)
sudo paccache -r
# Clean all cached packages
sudo pacman -Sc
# Clean everything (including installed)
sudo pacman -Scc
APT (Debian/Ubuntu)
Installation
# Update repos first (important!)
sudo apt update
# Single package
sudo apt install nginx
# Multiple packages
sudo apt install nginx php-fpm mariadb-server
# Specific version
sudo apt install nginx=1.24.0-1
# From local deb
sudo apt install ./package.deb
# or
sudo dpkg -i package.deb && sudo apt install -f
Removal
# Remove package
sudo apt remove nginx
# Remove with config files
sudo apt purge nginx
# Remove unused dependencies
sudo apt autoremove
# Remove + purge + autoremove
sudo apt purge nginx && sudo apt autoremove
Updates
# Update package lists (metadata only)
sudo apt update
# Upgrade installed packages
sudo apt upgrade
# Full upgrade (handles dependency changes)
sudo apt full-upgrade
# Distribution upgrade
sudo apt dist-upgrade
Search & Info
# Search
apt search nginx
# Package info
apt show nginx
# Policy (versions and repos)
apt policy nginx
# List installed
apt list --installed
# List upgradable
apt list --upgradable
# List files (installed)
dpkg -L nginx
# Find package owning file
dpkg -S /usr/sbin/nginx
Repositories
# List repos
cat /etc/apt/sources.list
ls /etc/apt/sources.list.d/
# Add PPA (Ubuntu)
sudo add-apt-repository ppa:ondrej/php
sudo apt update
# Add repo manually
echo "deb https://example.com/repo stable main" | \
sudo tee /etc/apt/sources.list.d/example.list
# Add GPG key
curl -fsSL https://example.com/gpg.key | \
sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/example.gpg
RPM Commands (Low Level)
# Query all installed
rpm -qa
# Query specific package
rpm -q nginx
# Query package info
rpm -qi nginx
# List files in package
rpm -ql nginx
# Find package owning file
rpm -qf /usr/sbin/nginx
# Verify package
rpm -V nginx
# Install RPM directly
sudo rpm -ivh package.rpm
# Upgrade RPM
sudo rpm -Uvh package.rpm
# Remove RPM (use dnf instead)
sudo rpm -e nginx
DPKG Commands (Low Level)
# List all installed
dpkg -l
# Query package
dpkg -s nginx
# List files
dpkg -L nginx
# Find owner
dpkg -S /usr/sbin/nginx
# Install deb directly
sudo dpkg -i package.deb
# Fix broken dependencies after dpkg
sudo apt install -f
# Remove
sudo dpkg -r nginx
# Purge (with config)
sudo dpkg -P nginx
# Reconfigure package
sudo dpkg-reconfigure nginx
Quick Reference Card
# === Install ===
dnf install pkg # RHEL/Fedora
pacman -S pkg # Arch
apt install pkg # Debian/Ubuntu
# === Remove ===
dnf remove pkg # RHEL/Fedora
pacman -Rns pkg # Arch (with deps+config)
apt purge pkg # Debian/Ubuntu (with config)
# === Update Everything ===
dnf upgrade # RHEL/Fedora
pacman -Syu # Arch
apt update && apt upgrade # Debian/Ubuntu
# === Search ===
dnf search term # RHEL/Fedora
pacman -Ss term # Arch
apt search term # Debian/Ubuntu
# === What package owns file? ===
rpm -qf /path/to/file # RHEL/Fedora
pacman -Qo /path/to/file # Arch
dpkg -S /path/to/file # Debian/Ubuntu
# === List files in package ===
rpm -ql pkg # RHEL/Fedora
pacman -Ql pkg # Arch
dpkg -L pkg # Debian/Ubuntu