Package manager commands¶
Synopsis¶
apt [OPTIONS] COMMAND [PACKAGE ...] dpkg ACTION [PACKAGE | FILE ...]
dnf [OPTIONS] COMMAND [PACKAGE-SPEC ...] rpm {-q | -i | -U | -e | -V} [OPTIONS] [PACKAGE | FILE ...]
pacman OPERATION [OPTIONS] [TARGET ...] (OPERATION: -S, -R, -Q, -U, -F, -D, -T)
emerge [OPTIONS] [ACTION] [ATOM | @SET ...] qlist, qfile, qlop, … (portage-utils); equery (gentoolkit)
Description¶
Each distribution family has a high-level package manager that works with repositories and resolves dependencies, and, except on Arch, a lower-level tool that works with installed packages and package files:
| Family | High-level tool | Low-level tool | Package names |
|---|---|---|---|
| Debian/Ubuntu | apt (interactive), apt-get and apt-cache (stable interface for scripts) |
dpkg, dpkg-query |
name, name=version |
| RHEL/Alma/Rocky | dnf (dnf 4; yum is a link to it) |
rpm |
name, name-version-release, globs |
| Arch | pacman |
pacman |
name, repo/name |
| Gentoo | emerge (Portage) |
Portage; portage-utils and gentoolkit for queries |
atoms: category/name, =category/name-version, >=category/name-version, category/name::repository |
Commands that change the system need root.
Query commands work as an unprivileged user, except that qlop reads /var/log/emerge.log, which only root and members of the portage group can read, and refreshing file lists (apt-file update, pacman -Fy) needs root.
In the tables, <PKG> is a package name, <VER> a version, <FILE> a path, <TERM> a search term, <NAME> a command's file name, <ID> a transaction number from the history list, and <REPO> a repository's name; in dnf's cache directory names, <HASH> is a string of hexadecimal digits that dnf adds to the name.
apt prints WARNING: apt does not have a stable CLI interface when its output isn't a terminal; scripts use apt-get and apt-cache, whose options and output format are stable.
Checked against apt 3.0.3 and dpkg 1.22.22 on Debian 13; apt 3.2.0 and dpkg 1.23.7 on Ubuntu 26.04; dnf 4.20.0 and RPM 4.19.1.1 on AlmaLinux 10.2 and Rocky Linux 10.2; pacman 7.1.0 on Arch Linux; Portage 3.0.83, portage-utils 0.97.1 and gentoolkit 0.8.2 on Gentoo (November 2026).
Repository metadata¶
| Task | apt | dnf | pacman | Portage |
|---|---|---|---|---|
| Refresh repository metadata | apt update |
dnf makecache (also refreshed automatically when older than metadata_expire) |
pacman -Sy, only together with -u |
emerge --sync, emaint sync --auto, or emerge-webrsync |
| List configured repositories | apt-cache policy |
dnf repolist --all |
pacman-conf --repo-list |
portageq get_repos / |
| Refresh file lists for file searches | apt-file update (package apt-file) |
Included in the metadata | pacman -Fy |
Not applicable: there is no file index |
Search and inspect¶
| Task | apt | dnf | pacman | Portage |
|---|---|---|---|---|
| Search names and descriptions | apt search <TERM> |
dnf search <TERM> |
pacman -Ss <TERM> |
emerge --searchdesc <TERM> |
| Search names only | apt search --names-only <TERM> |
dnf list '*<TERM>*' |
pacman -Slq \| grep '<TERM>' |
emerge --search <TERM> |
| Show details of a package | apt show <PKG> |
dnf info <PKG> |
pacman -Si <PKG> (repository), pacman -Qi <PKG> (installed) |
emerge --pretend --verbose <PKG>, equery meta <PKG> |
| Show available versions | apt-cache policy <PKG>, apt list --all-versions <PKG> |
dnf list --showduplicates <PKG> |
Only the current version is in the repositories | equery list --portage-tree <PKG> |
| Show dependencies | apt-cache depends <PKG> |
dnf repoquery --requires <PKG> |
pacman -Si <PKG> (Depends On) |
equery depgraph <PKG> |
| Show reverse dependencies | apt-cache rdepends --installed <PKG> |
dnf repoquery --installed --whatrequires <PKG> |
pacman -Qi <PKG> (Required By) |
equery depends <PKG> |
| Show whether a package was installed on request | apt-mark showmanual <PKG> prints the name if it was |
dnf history userinstalled lists packages installed on request |
pacman -Qi <PKG> (Install Reason) |
grep <PKG> /var/lib/portage/world |
Install, remove and upgrade¶
| Task | apt | dnf | pacman | Portage |
|---|---|---|---|---|
| Install | apt install <PKG> |
dnf install <PKG> |
pacman -S <PKG> |
emerge --ask <PKG> |
| Install a specific version | apt install <PKG>=<VER> |
dnf install <PKG>-<VER> |
pacman -U <FILE or URL> of that version |
emerge --ask =<PKG>-<VER> |
| Install a local package file | apt install ./<FILE>.deb |
dnf install ./<FILE>.rpm |
pacman -U <FILE>.pkg.tar.zst |
emerge --usepkgonly with the package in PKGDIR |
| Install as a dependency, not on request | apt install <PKG> then apt-mark auto <PKG> |
dnf mark remove <PKG> (removes the user-installed mark) |
pacman -S --asdeps <PKG> |
emerge --oneshot <PKG> |
| Reinstall | apt reinstall <PKG> |
dnf reinstall <PKG> |
pacman -S <PKG> |
emerge --oneshot <PKG> |
| Remove | apt remove <PKG> |
dnf remove <PKG> |
pacman -R <PKG> |
emerge --deselect <PKG>, then emerge --depclean |
| Remove with configuration files | apt purge <PKG> |
Not applicable: modified files are kept as .rpmsave |
pacman -Rn <PKG> |
Not applicable: files under CONFIG_PROTECT are kept |
| Remove unneeded dependencies | apt autoremove |
dnf autoremove |
pacman -Qdtq \| pacman -Rns - (reports argument '-' specified with empty stdin when there are none) |
emerge --depclean |
| Upgrade all packages | apt upgrade (never removes packages), apt full-upgrade |
dnf upgrade |
pacman -Syu |
emerge --ask --update --deep --newuse @world |
| List available upgrades | apt list --upgradable |
dnf check-update (exit status 100 when updates exist) |
pacman -Qu after a refresh |
emerge --pretend --update --deep --newuse @world |
| Downgrade | apt install <PKG>=<VER> (--allow-downgrades with -y) |
dnf downgrade <PKG> |
pacman -U <FILE or URL> of the older version |
emerge --oneshot =<PKG>-<VER> with newer versions masked |
| Hold at the current version | apt-mark hold <PKG> |
dnf versionlock add <PKG> (package python3-dnf-plugin-versionlock) |
IgnorePkg = <PKG> in /etc/pacman.conf |
><PKG>-<VER> in /etc/portage/package.mask |
Unattended runs: apt-get -y (with DEBIAN_FRONTEND=noninteractive to suppress debconf questions), dnf -y, pacman --noconfirm, and emerge without --ask.
Installed packages and files¶
| Task | apt | dnf | pacman | Portage |
|---|---|---|---|---|
| List installed packages | apt list --installed, dpkg-query -W |
dnf list --installed, rpm -qa |
pacman -Q |
qlist -Iv |
| List packages installed on request | apt-mark showmanual |
dnf repoquery --userinstalled |
pacman -Qe |
cat /var/lib/portage/world |
| Show the installed version | dpkg-query -W <PKG> |
rpm -q <PKG> |
pacman -Q <PKG> |
qlist -Iv <PKG> |
| Find the package that owns a file | dpkg -S <FILE> |
rpm -qf <FILE> |
pacman -Qo <FILE> |
qfile <FILE>, equery belongs <FILE> |
| Find the package that provides a file (any package) | apt-file search <FILE> |
dnf provides <FILE> |
pacman -F <FILE> |
Not available locally |
| List the files of an installed package | dpkg -L <PKG> |
rpm -ql <PKG> |
pacman -Ql <PKG> |
qlist <PKG>, equery files <PKG> |
| List the files of any package | apt-file list <PKG> |
dnf repoquery --list <PKG> |
pacman -Fl <PKG> |
Not available locally |
| List configuration files of a package | dpkg-query -W -f '${Conffiles}\n' <PKG> |
rpm -qc <PKG> |
pacman -Qii <PKG> (Backup Files) |
Not applicable |
| Check installed files against the package | dpkg --verify <PKG> |
rpm -V <PKG> |
pacman -Qkk <PKG> |
qcheck <PKG>, equery check <PKG> |
Paths are matched as the package recorded them.
On Debian 13 and Ubuntu 26.04, packages record files under /usr, so dpkg -S /bin/<NAME> fails where dpkg -S /usr/bin/<NAME> succeeds.
On Gentoo, many packages record /bin and /sbin paths, so qfile /usr/bin/<NAME> can fail where qfile /bin/<NAME> succeeds.
rpm -qf and pacman -Qo resolve symbolic links in the directory part of the path.
Cache¶
| Task | apt | dnf | pacman | Portage |
|---|---|---|---|---|
| Location of downloaded packages | /var/cache/apt/archives/ |
/var/cache/dnf/<REPO>-<HASH>/packages/ |
/var/cache/pacman/pkg/ |
/var/cache/distfiles/ (sources), /var/cache/binpkgs/ (own binary packages), /var/cache/binhost/<REPO>/ (downloaded binary packages) |
| Kept after installation by default | Kept by apt-get; deleted by apt |
No (keepcache=False) |
Yes, every version | Sources yes; binary packages yes |
| Remove all cached packages | apt clean |
dnf clean packages (dnf clean all also removes metadata) |
pacman -Scc |
No command; eclean-dist --deep and eclean-pkg --deep keep only files for installed versions |
| Remove only obsolete cached packages | apt autoclean |
Not applicable | pacman -Sc (versions no longer installed), paccache -r (keep the last three; package pacman-contrib) |
eclean-dist, eclean-pkg (files for versions no longer in the repository) |
History¶
| Task | apt | dnf | pacman | Portage |
|---|---|---|---|---|
| Log of changes | /var/log/apt/history.log (rotated to history.log.N.gz), /var/log/dpkg.log; apt history-list on Ubuntu 26.04 |
dnf history list (database in /var/lib/dnf/) |
/var/log/pacman.log |
/var/log/emerge.log, qlop |
| Show one transaction | apt history-info <ID> (Ubuntu 26.04, apt 3.2; not in Debian 13's apt 3.0) |
dnf history info <ID> |
Not applicable | qlop --verbose <PKG> for one package |
| Undo one transaction | apt history-undo <ID> (Ubuntu 26.04 only; with apt 3.2.0, undoing an upgrade doesn't downgrade the packages) |
dnf history undo <ID> |
Not applicable | Not applicable |
| Return to the state after a transaction | apt history-rollback <ID> (Ubuntu 26.04 only) |
dnf history rollback <ID> |
Not applicable | Not applicable |
Undo and rollback need every package version involved to still be available from a repository or the cache.
Examples¶
Show which package owns /usr/bin/lsblk and which version is installed:
Files¶
| Path | Family | Purpose |
|---|---|---|
/var/lib/dpkg/status |
Debian/Ubuntu | Installed packages and their states, including holds |
/var/lib/apt/extended_states |
Debian/Ubuntu | Which packages were installed automatically |
/var/lib/apt/lists/ |
Debian/Ubuntu | Downloaded repository indexes |
/usr/lib/sysimage/rpm/ |
RHEL/Alma/Rocky | RPM database (rpmdb.sqlite); /var/lib/rpm is a link to it |
/var/lib/dnf/ |
RHEL/Alma/Rocky | dnf history database |
/var/cache/dnf/ |
RHEL/Alma/Rocky | Repository metadata and downloaded packages |
/var/lib/pacman/local/ |
Arch | Installed-package database |
/var/lib/pacman/sync/ |
Arch | Repository databases (*.db) and file databases (*.files) |
/var/db/pkg/ |
Gentoo | Installed-package database (one directory per package) |
/var/lib/portage/world |
Gentoo | The @world set: packages installed on request |
/var/db/repos/gentoo/ |
Gentoo | The Gentoo ebuild repository |
See also¶
apt(8),apt-get(8),apt-cache(8),apt-mark(8),dpkg(1),dpkg-query(1)(apt 3.0 and 3.2, dpkg 1.22 and 1.23)dnf(8)(installed asdnf4(8)on RHEL 10),rpm(8)(dnf 4.20, RPM 4.19)pacman(8),pacman.conf(5),pacman-key(8)(pacman 7.1)emerge(1),portage(5),make.conf(5)(Portage 3.0);qlist(1),qfile(1),qlop(1);equery(1)- Debian Reference: Debian package management
- DNF command reference
- Gentoo Handbook: Portage
Related¶
- Reference: Repository configuration
- Explanation: How package management works
- Explanation: Binary and source distributions
- How-to: How to find which package provides a file
- How-to: How to add a third-party repository safely
- How-to: How to hold a package at its current version
- How-to: How to roll back a package update