Package Management - dpkg/apt and rpm/yum/dnf
What You Will Achieve
- Explain the division of roles between Debian (
dpkg/apt) and RPM (rpm/yum/dnf) - Distinguish the dependency-resolution difference between low-level tools (
dpkg/rpm) and high-level tools (apt/dnf) - Run install, remove, update, search, and query operations on both families
- Reverse-look up which package owns a file with
dpkg -S/rpm -qf - Answer the exam-frequent "
dpkg -idoes not resolve dependencies" with reasoning
This article covers both LPIC-1 objective 102.4 "Use Debian package management" and 102.5 "Use RPM and YUM package management" in one piece.
How to Choose Among the Two Families and Four Tools
Package management tools split into two layers: "low-level" (single-package operations, no dependency resolution) and "high-level" (repository-aware, automatic dependency resolution). The rule of thumb is to use high-level tools day to day and reserve low-level tools for queries or directly installing a local .deb/.rpm.
| Family | Low-level (no dep resolution) | High-level (resolves deps) | Repository config |
|---|---|---|---|
| Debian | dpkg |
apt / apt-get / apt-cache |
/etc/apt/sources.list(.d/) |
| RPM | rpm |
yum / dnf |
/etc/yum.repos.d/ |
A memory aid: dpkg and rpm are the low-level tools that "touch individual packages directly". apt, yum, and dnf are the high-level tools that "take care of repositories and dependencies". The exam frequently asks "which one resolves dependencies automatically".
Debian Family: Working with dpkg
dpkg is the low-level tool for Debian systems. It directly installs a local .deb file and queries installed packages. Its defining trait is that it does not resolve dependencies.
dpkg -i: Install a .deb directly
dpkg -i package_1.0_amd64.deb
Selecting previously unselected package package. (Reading database ... 180000 files and directories currently installed.) Preparing to unpack package_1.0_amd64.deb ... Unpacking package (1.0) ... Setting up package (1.0) ...
-i (--install) unpacks and configures the .deb. If required dependencies are missing it stops with dependency problems (see Troubleshooting below).
dpkg -r / -P: Remove
dpkg -r package dpkg -P package
-r (--remove) removes the package but keeps its configuration files; -P (--purge) removes it including configuration files. The "keep vs. delete config" distinction is tested on the exam.
dpkg -l / -L / -S: Query
dpkg -l # List installed packages dpkg -L package # List files placed by a package dpkg -S /usr/bin/which # Reverse-look up which package owns a file
debianutils: /usr/bin/which
-l (list) lists installed packages, -L (list files) lists "the files a package placed", and -S (search) reverse-looks up "which package this file belongs to". Note that -L and -S point in opposite directions.
dpkg --configure: Configure unconfigured packages
dpkg --configure -a
Configures packages that are unpacked but not yet configured. -a targets all such packages. Use it to recover when an installation was interrupted midway.
Debian Family: Working with apt / apt-get / apt-cache
The apt family is repository-aware and resolves dependencies automatically. apt is for interactive daily use, while apt-get / apt-cache provide a stable interface for scripts.
apt update / install / upgrade
apt update # Update package information (indexes) apt install package # Install with dependency resolution apt upgrade # Upgrade all upgradable packages
Reading package lists... Done Building dependency tree... Done The following additional packages will be installed: libfoo1 libbar2 ...
apt update only fetches the repository indexes; it does not upgrade packages themselves. The actual upgrade is apt upgrade. This division of roles is an exam-frequent point. apt install automatically pulls in missing dependencies (such as libfoo1 above).
apt remove / purge
apt remove package # Remove but keep configuration apt purge package # Remove including configuration
apt remove is equivalent to dpkg -r (keeps config) and apt purge is equivalent to dpkg -P (deletes config). The distinction mirrors dpkg.
apt-cache search / show (apt search / show)
apt-cache search keyword # Search packages by keyword apt-cache show package # Show detailed package information
nginx - small, powerful, scalable web/proxy server nginx-core - nginx web/proxy server (standard version)
search finds a target package by name or description before installing. show displays metadata such as version, dependencies, and description. apt search / apt show do the same thing.
aptitude is another high-level tool equivalent to apt, with an interactive TUI and advanced dependency resolution. For LPIC-1 it is enough to know its name and role (an alternative apt-family frontend).
RPM Family: Working with rpm
rpm is the low-level tool for RPM systems (Red Hat / Fedora / openSUSE family). Like dpkg, it handles single-package installation and queries and does not resolve dependencies.
rpm -i / -U / -e: Install, upgrade, erase
rpm -ivh package-1.0.x86_64.rpm # Fresh install rpm -Uvh package-2.0.x86_64.rpm # Upgrade (or install if absent) rpm -e package # Erase (remove)
-i (install) is a fresh install, -U (upgrade) upgrades an existing package or installs it if absent, and -e (erase) removes it. -v (verbose) and -h (show progress with hash marks) are commonly combined.
The rpm -q family: Query
rpm -qa # All installed packages rpm -qi bash # Detailed info for a package rpm -ql bash # List files placed by a package rpm -qf /bin/bash # Reverse-look up which package owns a file
bash-5.1.8-9.el9.x86_64
Queries always take -q (query): -qa (list all), -qi (info), -ql (list files), -qf (file reverse lookup). -ql and -qf correspond to dpkg's -L / -S and likewise point in opposite directions.
rpm -V: Verify
rpm -V bash
Verifies whether files were modified or corrupted after installation (size, permissions, MD5, and so on). No output means no change; characters such as S (size) or M (mode) indicate a difference in that attribute.
rpm2cpio package.rpm | cpio -idmv extracts files from a .rpm without installing it. It is the standard way to rescue a single file. For LPIC-1, knowing its existence and purpose is enough.
RPM Family: Working with yum / dnf
yum and its successor dnf are the high-level tools for RPM systems. They work with repositories (/etc/yum.repos.d/) and resolve dependencies automatically. Their command sets are nearly identical, and dnf is the default on newer distributions.
dnf install / remove / update
dnf install package # Install with dependency resolution dnf remove package # Remove dnf update # Upgrade all upgradable packages
Dependencies resolved. ================================================================ Package Arch Version Repository Size ================================================================ Installing: package x86_64 1.0-1.el9 appstream 120 k Installing dependencies: libfoo x86_64 2.3-4.el9 baseos 45 k ...
dnf install automatically pulls in missing dependencies (such as libfoo above). Writing yum install does the same thing (on many distributions yum is a link to dnf).
dnf search / info / list / repolist
dnf search keyword # Search packages by keyword dnf info package # Detailed package information dnf list installed # List installed packages dnf repolist # List enabled repositories
repo id repo name baseos Rocky Linux 9 - BaseOS appstream Rocky Linux 9 - AppStream
Use search to find, info to inspect details, list installed to check what is installed, and repolist to see which repositories are enabled. The repository configuration itself lives in .repo files under /etc/yum.repos.d/.
Side-by-Side Mapping of the Two Families
Mapping Debian and RPM commands per operation lets you infer one family from the other. Organize it around the fact that dependency resolution is the boundary between low-level and high-level.
| Operation | Debian low-level | Debian high-level | RPM low-level | RPM high-level |
|---|---|---|---|---|
| Install | dpkg -i |
apt install |
rpm -i |
dnf install |
| Upgrade | dpkg -i |
apt upgrade |
rpm -U |
dnf update |
| Remove | dpkg -r |
apt remove |
rpm -e |
dnf remove |
| Purge (incl. config) | dpkg -P |
apt purge |
rpm -e |
dnf remove |
| Search | — | apt-cache search |
— | dnf search |
| Detailed info | — | apt-cache show |
rpm -qi |
dnf info |
| List all packages | dpkg -l |
— | rpm -qa |
dnf list |
| List a package's files | dpkg -L |
— | rpm -ql |
— |
| File to package lookup | dpkg -S |
— | rpm -qf |
— |
| Automatic dep resolution | No | Yes | No | Yes |
Low-level tools (dpkg / rpm) do not resolve dependencies. To install something correctly along with its dependencies, always use a high-level tool (apt / dnf). When a directly installed local .deb / .rpm hits a dependency error, switching to the repository path (such as apt install ./pkg.deb) often resolves it.
Common Mistakes
Five errors that recur in both practice and the exam. All are avoidable once you understand "the low-level vs. high-level difference" and "the two-step update".
- Expecting dependency resolution from
dpkg -i: Installing a.debwithdpkg -istops withdependency problems. To resolve dependencies, useapt install ./pkg.deb. - Trying to ignore dependency errors with
rpm -e: Erasing something other packages depend on is refused withFailed dependencies. Do not recklessly force it with--nodeps; leaving it todnf removeis safer. - Forgetting
apt updateafter editingsources.list: Even after adding or changing a repository, new packages are not found until you refresh the indexes withapt update. - Confusing
apt updateandapt upgrade:updateonly refreshes information;upgradeactually upgrades packages. Do not assume the system is up to date just because you ranupdate. - rpm queries without
-q: Forgetting-q, as inrpm bash, when you mean to query does not give the intended result. Always write queries asrpm -q....
Troubleshooting
Symptom: dpkg -i stops with "dependency problems"
Cause: Because dpkg does not resolve dependencies, it fails at the configuration stage when required packages are not installed
Check:
dpkg -i package.deb
Fix: Leave it to a high-level tool that pulls in dependencies automatically.
apt install ./package.deb apt -f install
apt install ./package.deb installs the local .deb with dependency resolution. If the system is already in a broken state, apt -f install (--fix-broken) fills in the missing dependencies.
Symptom: rpm -e reports "Failed dependencies"
Cause: Another package depends on the one you are trying to erase
Check:
rpm -e package rpm -q --whatrequires package
Fix: Use the high-level tool that handles dependencies safely.
dnf remove package
dnf remove removes packages safely while considering dependencies. Avoid forced removal with rpm -e --nodeps, which can break the system.
Symptom: apt install cannot find the target package
Cause: The repository indexes are stale, or you did not refresh them after editing sources.list
Check:
cat /etc/apt/sources.list ls /etc/apt/sources.list.d/
Fix:
apt update apt install package
Refresh the indexes with apt update, then install again. For the same symptom on RPM systems, check the enabled repositories with dnf repolist.
Completion Checklist
- [ ] Can explain the roles of low-level (
dpkg/rpm) and high-level (apt/dnf) tools - [ ] Understand that
dpkg -i/rpm -ido not resolve dependencies - [ ] Can distinguish
apt updatefromapt upgrade - [ ] Can reverse-look up a package from a file with
dpkg -S/rpm -qf - [ ] Know where repository config lives (
/etc/apt/sources.list(.d/)//etc/yum.repos.d/)
Summary
| Role | Debian | RPM |
|---|---|---|
| Low-level | dpkg |
rpm |
| High-level | apt / apt-get / apt-cache |
yum / dnf |
| Install | apt install |
dnf install |
| Remove | apt remove / apt purge |
dnf remove |
| File lookup | dpkg -S |
rpm -qf |
| Repository | /etc/apt/sources.list(.d/) |
/etc/yum.repos.d/ |
Grasp package management through the contrast "low-level for single operations and queries, high-level for daily use with dependency resolution", and you can answer both 102.4 and 102.5 fluently. Next, combine it with filesystems and finding files to solidify the bigger picture of system administration.