apt, dnf and pacman Commands Compared: Package Manager Cheat Sheet

Side-by-side apt, dnf and pacman commands for searching, installing, removing, updating and inspecting packages, tested on Debian, Fedora and Arch.

Tools Published 4 min read

Contents

Debian and Ubuntu use apt, Fedora uses dnf, and Arch Linux uses pacman. These package manager commands do the same jobs with different syntax. This page maps the everyday tasks side by side, and every example was run in a container on Debian, Fedora and Arch.

The example package is tree, a small directory-listing tool. Run these as root, or prefix them with sudo.

Package manager command quick reference

Taskaptdnfpacman
Refresh package metadataapt updatednf upgrade --refresh (or --refresh on any command)pacman -Sy
Upgrade everythingapt upgradednf upgradepacman -Syu
Searchapt searchdnf searchpacman -Ss
Show repository infoapt showdnf infopacman -Si
Installapt installdnf installpacman -S
Removeapt removednf removepacman -R
Remove unused dependenciesapt autoremovednf autoremovepacman -Qdt, then pacman -Rs
List installedapt list --installeddnf list --installedpacman -Q
Installed package detailsapt showdnf infopacman -Qi
List files in a packagen/a herednf repoquery -lpacman -Ql

Refresh and upgrade

The three tools differ most here. With apt, update only downloads package information. upgrade then installs newer versions, but never removes installed packages. full-upgrade may remove packages when the upgrade needs it.

With dnf, upgrade updates every package to the latest resolvable version. Add --refresh to force a metadata sync. dnf check-update lists pending updates without changing anything and exits with 100 if updates exist.

With pacman, -y refreshes the sync databases and -u upgrades. The manual page says -y should typically be used each time you use -u, so -Syu is the normal form.

✓ tested · debian,ubuntu
apt update
apt upgrade -y
✓ tested · fedora
dnf upgrade -y --refresh
✓ tested · arch
pacman -Syu --noconfirm

Search and inspect before installing

Each tool can show what a package is before you install it.

✓ tested · debian,ubuntu
apt search '^tree$'
apt show tree
✓ tested · fedora
dnf search tree
dnf info tree
✓ tested · arch
pacman -Ss '^tree$'
pacman -Si tree

Search behavior differs. apt and pacman treat the term as a regular expression. dnf matches keywords as case-insensitive substrings against names and summaries.

Install

✓ tested · debian,ubuntu
apt install -y tree
✓ tested · fedora
dnf install -y tree
✓ tested · arch
pacman -S --noconfirm tree

On Arch, the examples run the full upgrade first. The pacman manual page says -y should typically be used each time you use -u.

Inspect what is installed

✓ tested · debian,ubuntu
apt list --installed 2>/dev/null | grep '^tree/'
apt show tree 2>/dev/null | head -n 5
✓ tested · fedora
dnf list --installed tree
dnf info --installed tree
dnf repoquery -l tree
✓ tested · arch
pacman -Q tree
pacman -Qi tree
pacman -Ql tree
pacman -Qo /usr/bin/tree

pacman can also answer “which package owns this file” with -Qo. dnf covers a similar question with dnf provides /usr/bin/tree, which searches file provides.

Remove

apt remove keeps small configuration files, while apt purge deletes them too. pacman’s -R saves modified config files with a .pacsave extension unless you pass --nosave. dnf’s remove also removes dependencies that are no longer needed by default (the clean_requirements_on_remove setting).

✓ tested · debian,ubuntu
apt purge -y tree
apt autoremove -y
✓ tested · fedora
dnf remove -y tree
dnf autoremove -y
✓ tested · arch
pacman -Rs --noconfirm tree

pacman -Rs removes the package plus dependencies that nothing else needs and that you did not install explicitly. To find existing orphans, run pacman -Qdt.

Once packages are installed, you may want to check what is using disk space; see Check disk usage on Linux with df, du and ncdu. Package updates are also how security fixes arrive, as in PHP RCE Fixes for CVE-2026-109618 and CVE-2026-109619. For a certificate-related example on Ubuntu, see eMudhra CA Compromise: Check Your Ubuntu System for the PKI Fix.

Sources

  1. apt(8) manual page (Debian trixie)
  2. DNF Command Reference
  3. pacman(8) manual page (Arch Linux)

#Apt #Dnf #Pacman #Package Manager #Cheat Sheet

This article was drafted with AI assistance, fact-checked against the sources listed above and reviewed by a human editor before publication. Spotted an error? See our corrections policy.