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
[bareos_bareos-16.2]
name=bareos bareos-16.2 (CentOS_7)
type=rpm-md
baseurl=http://download.bareos.org/bareos/release/16.2/CentOS_7/
gpgcheck=1
gpgkey=http://download.bareos.org/bareos/release/16.2/CentOS_7/repodata/repomd.xml.key
enabled=1

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

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
admin