Packages
rpmdb
Rebuild or manage the RPM database.
rpmdatabaserebuildpackage
Additional Notes
rpmdb manages the RPM package database stored under /var/lib/rpm. It is primarily used to rebuild the database if it becomes corrupted, or to migrate it between Berkeley DB versions. The RPM database tracks every installed package, including files, versions, dependencies, and metadata.
Database corruption can occur due to power loss, disk errors, or improper system shutdown. rpmdb provides tools to verify and rebuild the database from the installed package headers.
Syntax
rpmdb [options]
Parameters
options: Flags that change howrpmdbbehaves.target: Optional file, device, interface, user, service, or command target when the command supports one.
Common Options
--rebuilddb: Rebuild the RPM database from installed package headers. This reads all installed RPM headers and creates a fresh database.--initdb: Initialize a new RPM database. Creates the database files if they do not exist.--verify: Verify the integrity of the RPM database.--dump: Dump database contents in a human-readable format.--import: Import a public key into the RPM database.--export: Export all public keys from the RPM database.--all: Operate on all packages in the database (used with query modes).-v: Verbose output.
Examples
rpmdb --rebuilddb
Rebuild the RPM database from installed package headers.
rpmdb --initdb
Initialize a new empty RPM database.
rpmdb --verify
Check the RPM database for corruption.
Practical Notes
- The RPM database lives in
/var/lib/rpmand uses Berkeley DB format. - Always back up
/var/lib/rpmbefore running--rebuilddb. - A corrupted database will cause
rpmqueries and installations to fail. - Running
--rebuilddbrequires read access to all installed RPM headers. - The database files are named
Packages,Name,Basenames,Group, etc.