Linux package managers cheatsheet
This post isn't for the basic operations like installing stuff, because those are easy to remember or easy to figure out if you're missing them.
Glossary:
online package search: As the name says.
remove with dependencies: When uninstalling a package this will remove all packages it used to depend on alongside (unless they are required by something else). Useful if you are stripping down a system but also for general system hygiene.
minimal installation: Install a package without installing recommend dependencies. This is not always a good idea as parts that enable you to reasonably use a package may not be strictly required (and would thus be left off).
find unneeded: Find all packages that weren't explicitly installed or required by another package that was explicitly installed. Usually you can safely uninstall these without impacting anything you use.
why is package installed?: Find out why a certain package was installed. Either explicitly or as a dependency for another package, or because it's part of a standard installation set or such.
reinstall recommended: If you have used the 'minimal installation' method previously, this will reinstall packages you would have if you hadn't.
downgrade: Downgrade an installed package to a previous version (which is probably not stored on your system anymore).
up- or downgrade to match repo: Like an upgrade of everything, but ensure the installed packages exactly match what is provided in the repo. This does not always make sense.
APT-based (Debian, Ubuntu, ...)
online package search: https://packages.ubuntu.com/ or https://www.debian.org/distrib/packages
remove with dependencies: apt remove --autoremove
(--purge also deletes config files)
minimal installation: apt install --no-install-recommends
APT prominently notifies you if you have unnecessary packages installed, which I consider a very good UX choice.
downgrade: apt install $NAME=$VERSION
(use apt policy to see available versions)
DNF-based (Fedora, RHEL, ...)
online package search: https://packages.fedoraproject.org/ and others
remove with dependencies: default
minimal installation: dnf install --setopt=install_weak_deps=False
find unneeded: dnf list --autoremove
(dnf autoremove to uninstall directly)
downgrade: dnf install $NAME-$VERSION
(use dnf list --showduplicate to see available versions)
Arch Linux
online package search: https://archlinux.org/packages/
remove with dependencies: pacman -Rs
(-n also deletes config files)
minimal installation: default. If you want optional deps you have to install them manually.
find unneeded: pacman -Qdt
(-Qdtt to not consider optional deps)
why is package installed?
check pacman -Qi, e.g.
Name : abseil-cpp [...] Required By : protobuf re2 telegram-desktop webrtc-audio-processing-1 Optional For : None [...] Install Reason : Installed as a dependency for another package
or use pactree -r and you can probably instantly spot a package that you have explicitly installed.
reinstall recommended: not applicable
downgrade: not directly possible, requires old package files from separate source
up- or downgrade to match repo: pacman -Suu
openSUSE
online package search: https://software.opensuse.org/
remove with dependencies: zypper rm -u
minimal installation: zypper in --no-recommends
find unneeded: zypper pa -i --unneeded
why is package installed?
A good start is zypper se -v -i --requires-pkg $NAME or zypper se -v -i --recommends-pkg $NAME.
You may have to look at the installed patterns: zypper pt -i and e.g. zypper pattern-info enhanced_base
reinstall recommended: zypper inr or zypper inr --no-recommends (read documentation!)
downgrade: sudo zypper in --oldpackage $NAME=$VERSION
See available versions with zypper se -xs.
Tumbleweed doesn't have old versions in-repo, use the archive.
up- or downgrade to match repo: happens normally if you use zypper dup to install updates
For example on Tumbleweed you are always supposed to use dup over up.
Void Linux
online package search: https://voidlinux.org/packages/
remove with dependencies: xbps-remove -R
minimal installation: no equivalent
find unneeded: xbps-query -O
(xbps-remove -Ro to uninstall directly)
reinstall recommended: not applicable
up- or downgrade to match repo: xbps-install -uf (might be unsafe)
Alpine Linux
online package search: https://pkgs.alpinelinux.org/packages
remove with dependencies: apk del -r
Because apk doesn't ask before uninstalling, it's a good idea to test the command with -s first.
minimal installation: no equivalent
find unneeded: apk list -O
reinstall recommended: not applicable
up- or downgrade to match repo: apk upgrade --available
(necessary on release upgrades)