rpm command cheatsheet

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

<th>
  <strong>Description</strong>
</th>

<th>
  <strong>Example(s)</strong>
</th>
<td>
  Install the package
</td>

<td>
  rpm -ivh sendmail-cf-8.14.2-1.fc8.rpm<br /> rpm -ivh &#8211;test sendmail-8.14.2-1.fc8.rpm
</td>
<td>
  Upgrade package
</td>

<td>
  rpm -Uvh sendmail-cf-8.14.2-1.fc8.rpm<br /> rpm -Uvh &#8211;test sendmail-8.14.2-1.fc8.rpm
</td>
<td>
  Erase/remove/ an installed package
</td>

<td>
  rpm -ev sendmail
</td>
<td>
  Erase/remove/ an installed package without checking for dependencies
</td>

<td>
  rpm -ev &#8211;nodeps sendmail
</td>
<td>
  Display list all installed packages
</td>

<td>
  rpm -qa<br /> rpm -qa | less
</td>
<td>
  Display installed information along with package version and short description
</td>

<td>
  rpm -qi sendmail
</td>
<td>
  List files in package
</td>

<td>
  rpm -ql sendmail
</td>
<td>
  Find out what package a file belongs to i.e. find what package owns the file
</td>

<td>
  rpm -qf /etc/passwd<br /> rpm -qf /bin/bash
</td>
<td>
  Display list of configuration file(s) for a package
</td>

<td>
  rpm -qc httpd
</td>
<td>
  Display list of configuration files for a command
</td>

<td>
  rpm -qcf /usr/bin/locate
</td>
<td>
  Display list of all recently installed RPMs
</td>

<td>
  rpm -qa &#8211;last<br /> rpm -qa &#8211;last | less
</td>
<td>
  Find out what dependencies a rpm file has
</td>

<td>
  rpm -qpR sendmail-8.14.2-1.fc8.rpm<br /> rpm -qR bash
</td>
<td>
  Perform Installation Tests Only
</td>

<td>
  rpm -i &#8211;test rpm-2.0.11-1.i386.rpm<br /> /bin/rpm conflicts with file from rpm-2.3-1<br /> /usr/bin/gendiff conflicts with file from rpm-2.3-1<br /> /usr/bin/rpm2cpio conflicts with file from rpm-2.3-1<br /> /usr/bin/rpmconvert conflicts with file from rpm-2.3-1<br /> /usr/man/man8/rpm.8 conflicts with file from rpm-2.3-1<br /> error: rpm-2.0.11-1.i386.rpm cannot be installed
</td>
<td>
  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.
</td>

<td>
</td>
Syntax
rpm -ivh {rpm-file}
rpm -Uvh {rpm-file}
rpm -ev {package}
rpm -ev –nodeps {package}
rpm -qa
rpm -qi {package}
rpm -ql {package-name}
rpm -qf {/path/to/file}
rpm -qc {pacakge-name}
rpm -qcf {/path/to/file}
rpm -qa –last
rpm -qpR {.rpm-file}
rpm -qR {package}
rpm –test {package}
rpm –replacepkgs

{package} – Replace with actual package name