Installing software across distributions

apt, dnf, pacman, snap and flatpak, repository priorities, and what to do when no package exists.

The families and their tools

Linux distributions ship a package manager that resolves dependencies against signed repositories. The commands differ; the model is identical — refresh the index, then ask for a package by name.

FamilyLow-level toolInstallSearchQuery a file
Debian / Ubuntudpkgapt install nginxapt search nginxdpkg -S /usr/sbin/nginx
RHEL / Fedorarpmdnf install nginxdnf search nginxrpm -qf /usr/sbin/nginx
Archpacmanpacman -S nginxpacman -Ss nginxpacman -Qo /usr/bin/nginx
SUSErpmzypper install nginxzypper search nginxrpm -qf /usr/sbin/nginx
Alpineapkapk add nginxapk search nginxapk info --who-owns /usr/sbin/nginx
⚠️
Refreshing the index and upgrading are different operations. apt update only downloads metadata; apt upgrade changes installed packages. Never run an unattended full upgrade on a production host without a maintenance window and a snapshot, and never reach for --force-yes or dpkg --force-overwrite to push a broken dependency through.

apt and dpkg in practice

sudo apt update                     # refresh the package index
sudo apt install nginx
sudo apt install -y --no-install-recommends nginx   # leaner server install
sudo apt upgrade                    # safe, keeps packages back if needed
sudo apt full-upgrade               # may remove packages to satisfy dependencies

apt list --upgradable
apt-cache policy nginx              # installed vs candidate version, which repo
apt-cache show nginx | head -20

dpkg -l | grep nginx                # is it installed, and which version
dpkg -L nginx                       # every file the package shipped
dpkg -S /etc/nginx/nginx.conf       # which package owns this file

sudo apt-mark hold nginx            # freeze a version
sudo apt-mark unhold nginx
sudo apt autoremove                 # drop orphaned dependencies
# add a third-party repository the careful way
curl -fsSL https://example.com/key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/example.gpg
echo "deb [signed-by=/usr/share/keyrings/example.gpg] https://example.com/apt stable main" |
  sudo tee /etc/apt/sources.list.d/example.list
sudo apt update
  • A deb822 .sources file is the modern replacement for one-line .list entries; both forms work today.
  • Pinning (/etc/apt/preferences.d) decides which repository wins when two offer the same package.
  • If dpkg is interrupted, sudo dpkg --configure -a finishes the job before you install anything else.

Beyond the system package manager

OptionShipsBest for
Distribution packageSystem libraries linked inDaemons and anything a service depends on
snapSquashed image, auto-updatingDesktop apps and fast-moving toolchains
flatpakSandboxed runtime + appGUI applications with controlled permissions
Container imageWhole userspaceDeploying your own application
Build from sourceWhatever you compileA version or patch no repository carries
sudo dnf install nginx
sudo dnf history                     # every transaction, and its id
sudo dnf history undo 42             # roll one back
dnf provides "*/nginx.conf"          # which package ships this path

sudo pacman -Syu                     # refresh and upgrade together (Arch)

# building from source when no package fits
sudo apt install build-essential pkg-config
./configure --prefix=/usr/local && make -j"$(nproc)" && sudo make install
  • ./configure && make && make install leaves no record, so nothing upgrades or removes it later. Prefer checkinstall, or a static binary in /usr/local/bin, or a container.
  • Compiling with --prefix=/usr/local avoids fighting the distribution over /usr.
  • Whatever route you take, pin the version in a config file or an image tag so a rebuild produces the same result.

FAQ

apt says the package is already the newest version but my binary is old?
You are probably running a different binary earlier in PATH — check which -a nginx and dpkg -S. A leftover /usr/local install shadows the packaged one.
Is it safe to mix snap and apt versions of the same tool?
It works but invites confusion, because each has its own version, config location and upgrade timing. Pick one delivery channel per tool and make the shell find only that one.

Users, groups and privilege Archiving, syncing and backups

Last refreshed 2026-09-18.