High level tools handle metadata searching and dependency resolution
Low level tools handle installing and removing packages
Debian Family
High level: apt, apt-get, aptitude
Low level: dpkg
Red Hat Family
High Level: dnf, yum
Low level: rpm
Universal Package Managers
work across distros by bundling their own dependencies, independent of the host’s native package manager
snap
by Canonical
sandboxed
flatpak
by Red Hat
sandboxed
apt
apt-get is the older, stable, scriptable CLI - safe to use in scripts
apt is the newer high-level CLI meant for interactive use
apt adds: progress bars, color output, combined apt search, apt list
both call the same underlying libraries; no functional difference for common tasks
# refresh package index from all configured reposapt update# upgrade all installed packages to latest versionsapt upgrade# like upgrade, but also removes packages if needed to resolve depsapt full-upgrade# install a packageapt install <package># install a local packageapt install <file>.deb# remove package but keep config filesapt remove <package># remove package AND its config filesapt purge <package># remove orphaned dependencies no longer neededapt autoremove# search package names and descriptionsapt search <term># show metadata: version, deps, descriptionapt show <package># list all installed packagesapt list --installed
dpkg
low-level package tool that apt is built on top of
apt resolves dependencies then hands off to dpkg to do the actual install
works directly with .deb files on disk (no network, no repo)
# install a local .deb filedpkg -i <file>.deb# remove a package (keeps config)dpkg -r <package># remove a package AND its config filesdpkg --purge <package># list all installed packagesdpkg -l# check if a package is installeddpkg -s <package># list files installed by a packagedpkg -L <package># find which package owns a filedpkg -S /usr/bin/curl
dpkg -i do not have internet access and cannot do dependency resolution if the dependencies are missing
It is recommended to run apt install instead of dpkg -i for installing local debian files
If dpkg -i fails to install dependencies
the package gets into broken state
running apt install -f installs the missing dependencies
Repository management
/etc/apt/sources.list: main repo config file
/etc/apt/sources.list.d/: drop-in directory; one .list file per repo
# deb <url> <codename> <components...>deb https://deb.debian.org/debian bookworm main contrib non-free
components: buckets within a repo that separate packages by licensing and support policy
main: officially supported, open-source
contrib: open-source but depends on non-free packages
non-free / non-free-firmware: proprietary
Ubuntu adds its own:
universe: community-maintained open-source, not officially supported
Third-party repos hosted on Launchpad (Ubuntu only)
# add a PPAadd-apt-repository ppa:<user>/<repo># remove a PPAadd-apt-repository --remove ppa:<user>/<repo># list all configured reposapt-cache policy# list files in /etc/apt/sources.list.d/ls /etc/apt/sources.list.d/