Package Manager Cheatsheet

The same jobs, three spellings. This pairs with the package management post — read that for the why; keep this for the how. Columns are apt (Debian, Ubuntu), dnf (Alma, RHEL, Fedora) and pacman (Arch). Anything that changes the system wants sudo; the read-only queries do not.

Install and remove

Taskaptdnfpacman
Install a packageapt install foodnf install foopacman -S foo
Install a local fileapt install ./foo.debdnf install ./foo.rpmpacman -U foo.pkg.tar.zst
Remove a packageapt remove foodnf remove foopacman -R foo
Remove + its config + unused depsapt purge foodnf remove foopacman -Rns foo
Reinstallapt install --reinstall foodnf reinstall foopacman -S foo

Update and upgrade

Taskaptdnfpacman
Refresh the catalogueapt updatednf check-updatepacman -Sy
Upgrade everythingapt upgradednf upgradepacman -Su
Refresh and upgrade in oneapt update && apt upgradednf upgradepacman -Syu
Upgrade a single packageapt install --only-upgrade foodnf upgrade foopacman -S foo

Note

apt update refreshes the catalogue; it does not install anything. apt upgrade is what installs the newer versions. Never run upgrade without a fresh update first, or you are upgrading against yesterday’s list. On pacman, never -Sy without the u — a “partial upgrade” is a well-known way to break an Arch box.

Search and inspect

Taskaptdnfpacman
Search for a packageapt search foodnf search foopacman -Ss foo
Show details of a packageapt show foodnf info foopacman -Si foo
List installed packagesapt list --installeddnf list installedpacman -Q
Is this one installed?apt list --installed foodnf list installed foopacman -Qi foo
Which package owns a file?dpkg -S /path/to/filednf provides /path/to/filepacman -Qo /path/to/file
List files a package installeddpkg -L foorpm -ql foopacman -Ql foo

Housekeeping

Taskaptdnfpacman
Remove no-longer-needed depsapt autoremovednf autoremovepacman -Rns $(pacman -Qtdq)
Clear the download cacheapt cleandnf clean allpacman -Sc
List orphaned packagesapt-mark showautodnf repoquery --unneededpacman -Qtdq

Repositories and keys

Taskaptdnfpacman
List configured reposls /etc/apt/sources.list.d/dnf repolistcat /etc/pacman.conf
Add a third-party repoadd-apt-repository ppa:namednf config-manager --add-repo URLedit /etc/pacman.conf

Warning

Every third-party repo or PPA is a party you have granted root-level install rights on your machine, and nobody vets it but you. Add them deliberately, from sources you would vouch for. And never pipe a remote script straight into a root shell (curl … | sudo bash) without reading it first — download it, open it, then decide.

Universal packages

TaskSnapFlatpak
Installsnap install fooflatpak install foo
Removesnap remove fooflatpak uninstall foo
List installedsnap listflatpak list
Update everythingsnap refreshflatpak update

AppImage has no manager by design: chmod +x foo.AppImage then ./foo.AppImage. To remove one, delete the file.