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 {package}
Display installed information along with package version and short description
rpm -qi mozilla-mail
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

{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.

where are repositories defined?

similar to /etc/apt/sources.list you have files that define from what repositories packages can be downloaded

ll /etc/yum.repos.d

insgesamt 52K
drwxr-xr-x.   2 root root  248 22. Mai 15:03 .
drwxr-xr-x. 112 root root 8,0K 24. Mai 11:38 ..
-rw-r--r--.   1 root root  241 28. Okt 2016  bareos.repo
-rw-r--r--.   1 root root 1,7K 29. Nov 19:12 CentOS-Base.repo
-rw-r--r--.   1 root root 1,3K 29. Nov 19:12 CentOS-CR.repo
-rw-r--r--.   1 root root  649 29. Nov 19:12 CentOS-Debuginfo.repo
-rw-r--r--.   1 root root  314 29. Nov 19:12 CentOS-fasttrack.repo
-rw-r--r--.   1 root root  630 29. Nov 19:12 CentOS-Media.repo
-rw-r--r--.   1 root root 1,3K 29. Nov 19:12 CentOS-Sources.repo
-rw-r--r--.   1 root root 2,9K 29. Nov 19:12 CentOS-Vault.repo
-rw-r--r--.   1 root root  957 27. Dez 18:37 epel.repo
-rw-r--r--.   1 root root 1,1K 27. Dez 18:37 epel-testing.repo

cat bareos.repo; # display one example file
name=bareos bareos-16.2 (CentOS_7)

cat CentOS-Base.repo; # display one example file

# CentOS-Base.repo
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.

name=CentOS-$releasever - Base

#released updates
name=CentOS-$releasever - Updates

#additional packages that may be useful
name=CentOS-$releasever - Extras

#additional packages that extend functionality of existing packages
name=CentOS-$releasever - Plus