rpm is a powerful Package Manager for Red Hat, Suse and Fedora Linux. It can be used to build, install, query, verify, update, and remove/erase individual software packages. A Package consists of an archive of files, and package information, including name, version, and description.

rpm command cheat sheet for Linux

Syntax Description Example(s)
rpm -ivh {rpm-file}
Install the package
rpm -ivh mozilla-mail-1.7.5-17.i586.rpm

rpm -ivh --test mozilla-mail-1.7.5-17.i586.rpm
rpm -Uvh {rpm-file}
Upgrade package
rpm -Uvh mozilla-mail-1.7.6-12.i586.rpm

rpm -Uvh --test mozilla-mail-1.7.6-12.i586.rpm
rpm -ev {package}
Erase/remove/ an installed package
rpm -ev mozilla-mail
rpm -ev --nodeps {package}
Erase/remove/ an installed package without checking for dependencies
rpm -ev --nodeps mozilla-mail
rpm -qa
Display list all installed packages
rpm -qa

rpm -qa | less
rpm -qi {PackageName}
Display installed information along with package version and short description
rpm -qi mozilla-mail
rpm -qpi /path/to/package.rpm
Display installed information along with package version and short description
rpm -qpi /software/storagecraft-repo-latest.rpm
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/X11R6/bin/xeyes
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 mediawiki-1.4rc1-4.i586.rpm

rpm -qR bash
rpm2cpio /path/package.rpm > output.cpio
cpio -i --make-directories < output.cpio
extract / unpack all files of that package
rpm2cpio /path/package.rpm | cpio -idmv

{package} – Replace with actual package name

src: https://www.cyberciti.biz/howto/question/linux/linux-rpm-cheat-sheet.php

additional stuff:

rpm --query --list nmap-ncat-6.40-7.el7.x86_64; # list all files that belong to this package

rpm --query --docfiles nmap-ncat-6.40-7.el7.x86_64; # list all docfiles of that package

rpm --query --list --docfiles package; # list all docfiles of that package

Verifying a package

rpm -vvv --verify emacs.x86_64; # very verbosely verify the installed package taking into account timestamp, md5 checksum and file size

compares information about the installed files in the package with information about the files taken from the package metadata stored in the rpm database.

Among other things, verifying compares the size, digest, permissions, type, owner and group of each file. Any discrepancies are displayed.

Files that were not installed from the package, for example, documentation files excluded on installation using the “–excludedocs” option, will be silently ignored.

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin