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.
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
| Task | apt | dnf | pacman |
|---|---|---|---|
| Refresh package metadata | apt update | dnf upgrade --refresh (or --refresh on any command) | pacman -Sy |
| Upgrade everything | apt upgrade | dnf upgrade | pacman -Syu |
| Search | apt search | dnf search | pacman -Ss |
| Show repository info | apt show | dnf info | pacman -Si |
| Install | apt install | dnf install | pacman -S |
| Remove | apt remove | dnf remove | pacman -R |
| Remove unused dependencies | apt autoremove | dnf autoremove | pacman -Qdt, then pacman -Rs |
| List installed | apt list --installed | dnf list --installed | pacman -Q |
| Installed package details | apt show | dnf info | pacman -Qi |
| List files in a package | n/a here | dnf repoquery -l | pacman -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.
apt update
apt upgrade -ydnf upgrade -y --refreshpacman -Syu --noconfirmSearch and inspect before installing
Each tool can show what a package is before you install it.
apt search '^tree$'
apt show treednf search tree
dnf info treepacman -Ss '^tree$'
pacman -Si treeSearch behavior differs. apt and pacman treat the term as a regular expression. dnf matches keywords as case-insensitive substrings against names and summaries.
Install
apt install -y treednf install -y treepacman -S --noconfirm treeOn 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
apt list --installed 2>/dev/null | grep '^tree/'
apt show tree 2>/dev/null | head -n 5dnf list --installed tree
dnf info --installed tree
dnf repoquery -l treepacman -Q tree
pacman -Qi tree
pacman -Ql tree
pacman -Qo /usr/bin/treepacman 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).
apt purge -y tree
apt autoremove -ydnf remove -y tree
dnf autoremove -ypacman -Rs --noconfirm treepacman -Rs removes the package plus dependencies that nothing else needs and that you did not install explicitly. To find existing orphans, run pacman -Qdt.
Related guides
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
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.