These are some useful rpm commands:

NOTE: All example commands use apache-1.3.6-1.i386.rpm, replace it with the package name of your choice


INSTALLATION/UNINSTALLATION

Install a package

# rpm -ivh apache-1.3.6-1.i386.rpm

Reinstall a package

# rpm -ivh --replacepkgs apache-1.3.6-1.i386.rpm

Force package installation (even when a required package is not installed)

# rpm -vh --nodeps apache-1.3.6-1.i386.rpm

Upgrade a package

# rpm -Uvh apache-1.3.6-1.i386.rpm

Freshen a package

# rpm -Fvh apache-1.3.6-1.i386.rpm

The difference between freshen and upgrade is that upgrade (-U) installs the package even if a previous version of the package does not exists; freshen (-F) only performs the upgrade only if a previous version the package was already installed)

Uninstall a package

# rpm -e apache

Note that only the name of the package is required, no version number is needed

Force uninstallation, even if the package is required by another installed package

# rpm -e --nodeps apache

QUERY

List all installed packages

# rpm -qa

Show information about a package

If the package is installed: 
# rpm -qi apache

If the package is not installed:
# rpm -qpi apache-1.3.6-1.i386.rpm

List all the files that belong to a package

If the package is installed: 
# rpm -ql apache

If the package is not installed: 
# rpm -qpl apache-1.3.6-1.i386.rpm

List the documentation files of a package

If the package is installed:
# rpm -qd apache

If the package is not installed:
# rpm -qpd apache-1.3.6-1.i386.rpm

Determine which package a specific file belongs to

# rpm -qf /usr/bin/ls

Verification

Verify an installed package

# rpm -V apache

Verify all installed packages

# rpm -Va

Verify the package a specific file belongs to

# rpm -Vf /usr/bin/apache

Verify an installed package against a RPM file

# rpm -Vp apache-1.3.6-1.i386.rpm

Determine if a RPM file is corrupt

# rpm -K apache-1.3.6-1.i386.rpm

If the output of the above command contains the string ‘md5 OK’, then the package is not corrupt (very useful to check the validity of downloaded package files)

Share!