2.9 KiB
📦 Managing Packages with rpm on RHEL/CentOS
The rpm command (RPM Package Manager) is the low-level package management tool used on Red Hat-based systems such as RHEL, CentOS, Fedora, and others. Unlike yum, rpm does not resolve dependencies automatically and is best used for advanced or manual package management.
Below are the core rpm commands categorized and explained.
📥 1. Installing Packages
rpm -i <file.rpm>
rpm --install <file.rpm>
Installs a new .rpm package file. This command will fail if the package's dependencies are not already installed.
rpm -i <file.rpm>
or
rpm --install <file.rpm>
💡 Tip: Use
yum localinstallordnf installinstead for dependency resolution.
🔄 2. Upgrading Packages
rpm -U <file.rpm>
rpm --upgrade <file.rpm>
Upgrades an existing package if it is already installed. If the package is not already present, this command will install it.
rpm -U <file.rpm>
or
rpm --upgrade <file.rpm>
❌ 3. Removing Packages
rpm -e <package>
rpm --erase <package>
Removes a package from the system by name (not the filename). Note that this command also does not resolve dependencies, so it may break things if you're not careful.
rpm -e <package>
or
rpm --erase <package>
⚠️ Caution: Always check what depends on a package before removing it.
🔍 4. Querying Packages
rpm -q <package>
Query whether a package is installed, and show its version.
rpm -q <package>
rpm -qa
List all installed packages.
rpm -qa
rpm -qi <package>
Displays detailed information about a specific installed package.
rpm -qi <package>
rpm -ql <package>
Lists all files installed by a package.
rpm -ql <package>
rpm -qf <file>
Finds out which package owns a specific file.
rpm -qf /usr/bin/wget
rpm -qp <file.rpm>
Query a package file (without installing it) to see its metadata.
rpm -qp <file.rpm>
rpm -K <file.rpm>
Verifies the signature and integrity of an RPM package file.
rpm -K <file.rpm>
🛠️ 5. Verifying and Checking
rpm -V <package>
Verifies installed package files against their original metadata (modifications, corruption, etc.).
rpm -V <package>
rpm --test -i <file.rpm>
Simulates an install without actually installing the package — useful for testing.
rpm --test -i <file.rpm>
✅ Final Notes
rpmis a powerful low-level tool, but not recommended for resolving dependencies.- For automated dependency handling, prefer using
yumordnf. - Use
rpmwhen you need precise control over the package management process or are working with standalone.rpmfiles.