dpkg is the low-level package tool on Debian-family systems, while rpm serves a similar role for RPM-family systems. They unpack native archives, run package lifecycle actions, and update installed-package databases. Repository-aware tools such as APT and DNF build on these lower-level mechanisms.
Packages · Lesson 5
rpm and dpkg
Learn how `dpkg` and `rpm` inspect and modify their native package databases and local archives.
Inspecting an Archive Before Installation
A package archive is not equivalent to one executable file. It can contain many payload files, metadata, configuration handling, and privileged lifecycle scripts. Inspect its origin, signature or authenticated download path, metadata, and contents before installation.
Debian: $ dpkg-deb --info ./some-package.deb
Debian: $ dpkg-deb --contents ./some-package.deb
RPM: $ rpm -qip ./some-package.rpm
RPM: $ rpm -qlp ./some-package.rpm
The p in the shown RPM query forms means “query a package file” rather than the installed database. Query output helps review a package but cannot prove that its scripts or programs are safe.
Which low-level tool manages Debian .deb packages and their installed database?
Installing a Local Archive
Direct low-level installation uses:
Debian: $ sudo dpkg -i ./some-package.deb
RPM: $ sudo rpm -U ./some-package.rpm
dpkg -i can unpack and configure the requested archive, but it does not fetch missing repository dependencies. Raw rpm similarly does not provide the normal repository solver workflow. A higher-level command is usually preferable for a local archive because it can resolve dependencies from configured sources:
Debian: $ sudo apt install ./some-package.deb
RPM: $ sudo dnf install ./some-package.rpm
Review the transaction before confirming. A leading ./ distinguishes a local Debian archive path from a repository package name in APT.
Which shown command can install a local .deb while resolving available repository dependencies?
Removing an Installed Package
Removal targets an installed package name, not the archive filename used earlier:
Debian: $ sudo dpkg --remove package-name
RPM: $ sudo rpm --erase package-name
On Debian, --remove normally retains configuration files classified as conffiles; --purge requests their removal as well, subject to package scripts and unmanaged data. Neither command guarantees deletion of user-created data. Higher-level apt remove or dnf remove is generally better because it can evaluate related packages and present a complete transaction.
What operand does dpkg --remove expect for an installed package?
Querying Installed State
List installed or known package records with:
Debian: $ dpkg-query -l
RPM: $ rpm -qa
For targeted inspection, prefer a specific package name and machine-readable format where scripting reliability matters. Package databases describe managed state; local administrators or applications can still modify files afterward, so use verification features when you need to compare installed files with recorded metadata.
Which command queries all packages recorded as installed in the RPM database?
Use Managing Packages with RPM to practice archive queries and integrity checks in an isolated system.
Lesson complete
You finished rpm and dpkg
You can now distinguish low-level package operations from repository transactions.
Inspect local archive metadata and contents before installation.
Use
dpkgfor.debandrpmfor.rpmlow-level operations.Prefer APT or DNF when dependencies must be resolved.
Remove by installed package name and verify managed state separately.
Keep your learning progress
Create a free account to save this lesson and continue learning on any device.
Create a free account