rpm command cheatsheet

This is a simple cheatsheet for the rpm command and can be used on systems like RedHat that uses the command

Syntax Description Example(s)
rpm -ivh {rpm-file} Install the package rpm -ivh sendmail-cf-8.14.2-1.fc8.rpm
rpm -ivh –test sendmail-8.14.2-1.fc8.rpm
rpm -Uvh {rpm-file} Upgrade package rpm -Uvh sendmail-cf-8.14.2-1.fc8.rpm
rpm -Uvh –test sendmail-8.14.2-1.fc8.rpm
rpm -ev {package} Erase/remove/ an installed package rpm -ev sendmail
rpm -ev –nodeps {package} Erase/remove/ an installed package without checking for dependencies rpm -ev –nodeps sendmail
rpm -qa Display list all installed packages rpm -qa
rpm -qa | less
rpm -qi {package} Display installed information along with package version and short description rpm -qi sendmail
rpm -ql {package-name} List files in package rpm -ql sendmail
rpm -qf {/path/to/file} Find out what package a file belongs to i.e. find what package owns the file rpm -qf /etc/passwd
rpm -qf /bin/bash
rpm -qc {pacakge-name} Display list of configuration file(s) for a package rpm -qc httpd
rpm -qcf {/path/to/file} Display list of configuration files for a command rpm -qcf /usr/bin/locate
rpm -qa –last Display list of all recently installed RPMs rpm -qa –last
rpm -qa –last | less
rpm -qpR {.rpm-file}
rpm -qR {package}
Find out what dependencies a rpm file has rpm -qpR sendmail-8.14.2-1.fc8.rpm
rpm -qR bash
rpm –test {package} Perform Installation Tests Only rpm -i –test rpm-2.0.11-1.i386.rpm
/bin/rpm conflicts with file from rpm-2.3-1
/usr/bin/gendiff conflicts with file from rpm-2.3-1
/usr/bin/rpm2cpio conflicts with file from rpm-2.3-1
/usr/bin/rpmconvert conflicts with file from rpm-2.3-1
/usr/man/man8/rpm.8 conflicts with file from rpm-2.3-1
error: rpm-2.0.11-1.i386.rpm cannot be installed
rpm –replacepkgs Install the Package Even If Already Installed. Is used to force RPM to install a package that it believes to be installed already. This option is normally used if the installed package has been damaged somehow and needs to be fixed up.

{package} – Replace with actual package name