Linux RPM Command Guide

The rpm command is used to manage RPM packages in Linux. It allows you to install, update, query, verify, and remove software packages.

Basic Syntax

rpm [OPTIONS] PACKAGE_NAME

Common Options

Option Description Example
-i Install a package rpm -i package.rpm
-U Upgrade a package rpm -U package.rpm
-e Erase (remove) a package rpm -e package_name
-q Query a package rpm -q package_name
-f Find the package that owns a file rpm -f /path/to/file
-V Verify a package rpm -V package_name
-h Show hash marks during installation rpm -i -h package.rpm
-v Verbose output rpm -iv package.rpm
-a List all installed packages rpm -qa
-l List files in a package rpm -ql package_name
-d List documentation files of a package rpm -qd package_name
-c List configuration files of a package rpm -qc package_name
-s List files that are not part of any package rpm -qf /path/to/file
-K Check the signature of a package rpm -K package.rpm
-qa List all installed packages rpm -qa
-qc List configuration files of a package rpm -qc package_name
--test Test package installation without making changes rpm -i --test package.rpm
--verify Verify a package rpm --verify package_name

Examples

1. Installing a Package

rpm -i example-package.rpm

This command installs the specified RPM package.

2. Upgrading a Package

rpm -U example-package.rpm

This command upgrades an existing package or installs it if it's not already installed.

3. Removing a Package

rpm -e example-package

This command removes the specified package from the system.

4. Querying Installed Packages

rpm -qa

This command lists all installed packages on the system.

5. Verifying a Package

rpm --verify example-package

This command checks the integrity and authenticity of the specified package.

6. Install package without dependences

rpm -i --nodeps example-package.rpm

This command installs the specified package without checking for dependencies. Use with caution as it may lead to broken packages.

7. Install package forcefully

rpm -i --force example-package.rpm

This command installs the specified package forcefully, overwriting any existing files. Use with caution as it may lead to system instability.

8. Listing Files in a Package

rpm -ql example-package

This command lists all files that are part of the specified package.