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.

  • 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)

APT prominently notifies you if you have unnecessary packages installed, which I consider a very good UX choice.

minimal installation: apt install --no-install-recommends

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.

abseil-cpp
├─protobuf
│ ├─python-protobuf
│ │ └─anki
│ └─telegram-desktop
[...]

reinstall recommended: no equivalent

up- or downgrade to match repo: pacman -Su warns of packages that are newer than in the repo, but there's no straightforward way to downgrade them.

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!)

up- or downgrade to match repo: happens normally if you use zypper dup to install updates

For example on openSUSE 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: no equivalent

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: no equivalent

up- or downgrade to match repo: apk upgrade --available

(necessary on release upgrades)