Menu

Linux Installation and Package Management

Step 5 of 6 LPIC-1 102.5weight 3

Use RPM and YUM package management

“Install, upgrade, remove and query RPM packages with rpm, yum/dnf and zypper, check signatures, and find which package owns a file.”

View .md

Red Hat Enterprise Linux, Fedora, CentOS Stream, AlmaLinux, Rocky Linux, openSUSE and SUSE Linux Enterprise all use RPM packages. Just like on Debian, there are two layers, and you need both for the exam:

  • rpm is the low-level tool. It installs, removes, queries and verifies .rpm files and keeps the package database. It doesn’t download anything or resolve dependencies.
  • yum (and its successor dnf) on the Red Hat family, and zypper on SUSE, download from repositories, resolve dependencies, and use rpm underneath.

Follow along in a container: docker run -it --rm almalinux:9 (a free RHEL 9 rebuild) or docker run -it --rm fedora. You’re root there, so drop the sudo.

What an .rpm is#

text
tree-1.8.0-10.el9.x86_64.rpm
 │     │    │   │    └ architecture (x86_64, aarch64, noarch, i686)
 │     │    │   └ distribution tag (el9 = Enterprise Linux 9)
 │     │    └ release of the packaging
 │     └ upstream version
 └ package name

A package with noarch works on any CPU (scripts, docs). A .src.rpm holds source code to rebuild the package. Each package is a compressed archive of files plus a header with metadata, dependencies, install scripts and a digital signature. The database of installed packages lives in /var/lib/rpm/.

rpm: install, upgrade, remove#

CommandWhat it does
rpm -ivh file.rpmInstall. Fails if any version is already installed.
rpm -Uvh file.rpmUpgrade, or install if it isn’t there. The usual choice.
rpm -Fvh file.rpmFreshen: upgrade only if an older version is installed
rpm -e packageErase (remove) an installed package
rpm --reinstall -vh file.rpmReinstall the same version

-v is verbose and -h prints hash marks as a progress bar. Other options you’ll see: --test (dry run), --nodeps (ignore dependencies, risky) and --force (overwrite files and versions, risky). Kernels are usually installed with -i, not -U, so the old kernel stays as a fallback.

bash
dnf download tree            # get the .rpm file (install dnf-plugins-core if this command is missing)
sudo rpm -Uvh tree-1.8.0-10.el9.x86_64.rpm
text
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:tree-1.8.0-10.el9                ################################# [100%]

If a dependency is missing, rpm just stops with error: Failed dependencies: and a list. That’s exactly what dnf is for.

rpm: query#

Every query starts with -q. Add letters for what you want to know:

CommandShows
rpm -q treeIs it installed? Which version?
rpm -qaAll installed packages (rpm -qa 'kernel*' filters, --last sorts by install date)
rpm -qi treeInfo: version, vendor, build date, signature, description
rpm -ql treeList of files in the package
rpm -qc tree / rpm -qd treeOnly its config files / documentation
rpm -qf /usr/bin/treeWhich package owns this file
rpm -qR treeWhat it requires (dependencies)
rpm -q --whatrequires bashWhich installed packages need this capability
rpm -q --whatprovides libc.so.6Which installed package provides a capability
rpm -q --changelog tree / --scriptsPackage history / install and removal scripts
rpm -qpi file.rpm, rpm -qpl file.rpmThe same queries on a package file (-p) instead of the database
bash
rpm -qf /usr/bin/tree
rpm -qi tree | head -6
text
tree-1.8.0-10.el9.x86_64
Name        : tree
Version     : 1.8.0
Release     : 10.el9
Architecture: x86_64
Install Date: Tue 01 Dec 2026 10:12:44 AM UTC
Group       : Unspecified

rpm: verify integrity and signatures#

rpm -V compares installed files against the database. No output means everything matches. rpm -Va checks every package on the system.

bash
sudo rpm -V openssh-server
text
S.5....T.  c /etc/ssh/sshd_config

Each position is a test; a dot means it passed:

CodeMeaningCodeMeaning
SSize differsLSymlink target differs
MMode (permissions or type) differsUUser owner differs
5Checksum (digest) differsGGroup owner differs
DDevice number differsTModification time differs
PCapabilities differmissingThe file is gone

The letter before the path is the file type: c config, d documentation, l license, r readme. A changed config file is normal; a changed /usr/bin/ file isn’t.

Packages are signed with the distribution’s GPG key so you know they’re genuine and unchanged. The public keys sit in /etc/pki/rpm-gpg/:

bash
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-9   # trust a key
rpm -qa 'gpg-pubkey*'                                         # keys you trust
rpm -K tree-1.8.0-10.el9.x86_64.rpm                           # check a file (same as --checksig)
text
tree-1.8.0-10.el9.x86_64.rpm: digests signatures OK

Without the right key imported, you get digests SIGNATURES NOT OK.

rpm2cpio: unpack without installing#

Sometimes you want one file out of a package (a default config, a lost binary) without installing it. rpm2cpio turns an .rpm into a cpio archive, and cpio unpacks it into the current folder:

bash
mkdir /tmp/x && cd /tmp/x
rpm2cpio ~/tree-1.8.0-10.el9.x86_64.rpm | cpio -idmv
text
./usr/bin/tree
./usr/share/doc/tree/README
./usr/share/licenses/tree/LICENSE
./usr/share/man/man1/tree.1.gz
226 blocks

cpio -i extracts, -d creates folders, -m keeps file times, -v lists names. Use cpio -t instead to only list the contents.

yum and dnf#

YUM (Yellowdog Updater, Modified) was the RHEL/CentOS front end up to version 7. DNF replaced it in Fedora 22 and RHEL 8. The commands are nearly identical, and on RHEL 8 and 9 yum is simply a link to dnf, so everything below works with either name. Fedora 41 moved on to DNF5, still called with dnf.

CommandWhat it does
yum install treeInstall with dependencies (yum install ./file.rpm for a local file)
yum reinstall treeReinstall the same version
yum remove treeRemove (erase is an old alias)
yum update / yum upgradeUpgrade everything, or just the packages you name
yum check-updateList available updates without installing
yum search wordSearch names and summaries
yum info treeDetails about a package, installed or not
yum list installed / yum list availableInstalled / installable packages
yum provides /usr/bin/digWhich package (installed or not) has this file. Also whatprovides.
yum repolistEnabled repositories
yum history / yum history undo 5Past transactions, and undoing one
yum clean allDelete cached metadata and packages
yum group list / yum group install "Development Tools"Package groups
yumdownloader tree / dnf download treeDownload the .rpm without installing
bash
dnf provides /usr/bin/dig
text
bind-utils-32:9.16.23-24.el9_5.x86_64 : Utilities for querying DNS name servers
Repo        : appstream
Matched from:
Filename    : /usr/bin/dig

For a file name without a path, use a pattern in quotes: dnf provides '*/libssl.so.3'. To see what a package that isn’t installed contains, use dnf repoquery -l tree; for its dependencies, dnf repoquery --requires tree.

/etc/yum.conf and /etc/yum.repos.d/#

The main config is /etc/yum.conf. With DNF it’s /etc/dnf/dnf.conf, and on RHEL 8 and 9 /etc/yum.conf is a link to it. The [main] section holds global settings:

/etc/yum.confini
1[main]
2gpgcheck=1
3installonly_limit=3
4clean_requirements_on_remove=True
5best=True
6skip_if_unavailable=False

gpgcheck=1 refuses unsigned packages. installonly_limit=3 keeps three kernels installed. Old YUM also set cachedir=/var/cache/yum and keepcache here.

Repositories are defined in .repo files in /etc/yum.repos.d/, one section per repository:

/etc/yum.repos.d/example.repoini
1[example]
2name=Example packages for EL $releasever
3baseurl=https://repo.example.com/el/$releasever/$basearch/
4enabled=1
5gpgcheck=1
6gpgkey=https://repo.example.com/RPM-GPG-KEY-example

$releasever (like 9) and $basearch (like x86_64) are filled in for you. Instead of baseurl, a repo can use mirrorlist or metalink to pick a mirror. Set enabled=0 to switch it off, or use one-off flags: yum --enablerepo=example install foo, yum --disablerepo=example update. dnf config-manager --add-repo URL writes a .repo file for you.

zypper (SUSE)#

openSUSE and SLES use zypper. Most commands have a short form:

CommandShortWhat it does
zypper refreshrefRefresh repository metadata
zypper install treeinInstall (in -f or --force reinstalls)
zypper remove treermRemove
zypper updateupUpdate installed packages
zypper dist-upgradedupUpgrade the whole distribution (openSUSE Tumbleweed, release upgrades)
zypper list-updatesluShow available updates
zypper search treeseSearch (se -i for installed only)
zypper info treeifPackage details
zypper what-provides /usr/bin/treewpWhich package has a file or capability (same as se --provides)
zypper reposlrList repositories
zypper addrepo URL aliasarAdd a repository (removerepo, rr, to delete)

Repository files live in /etc/zypp/repos.d/. Try it with docker run -it --rm opensuse/leap. Because SUSE packages are RPMs, every rpm command above works there too.

Tip

Mixing tools is fine for queries: rpm -qf, rpm -qi and rpm -V are fast and work on every RPM system. For installing and removing, prefer dnf or zypper, so dependencies stay consistent.

Exam checklist#

  • rpm handles local files, no dependency resolution. yum/dnf and zypper resolve dependencies from repositories.
  • Install -i, upgrade -U, freshen -F (only if installed), erase -e, usually with -vh. --reinstall, --nodeps, --force, --test.
  • Queries: -qa, -qi, -ql, -qc, -qd, -qf file (owner), -qR (requires), --whatprovides, --whatrequires, and -qp... for a package file.
  • Verify with rpm -V / -Va: S size, M mode, 5 checksum, T time, c config file. Check signatures with rpm -K / --checksig, add keys with rpm --import.
  • rpm2cpio file.rpm | cpio -idmv extracts files without installing.
  • yum/dnf: install, reinstall, remove, update, check-update, search, info, list, provides, repolist, clean all. dnf replaced yum (RHEL 8+, Fedora).
  • Config: /etc/yum.conf (/etc/dnf/dnf.conf), repositories as .repo files in /etc/yum.repos.d/ with baseurl, enabled, gpgcheck, gpgkey.
  • zypper: in, rm, up, dup, se, if, ref, lr, ar, wp. Repos in /etc/zypp/repos.d/.

Byte check

0/3

Answer these 3 questions to commit this byte to your learning path.

  1. Which rpm command upgrades a package only if an older version is already installed?
  2. How do you see the files inside app.rpm without installing it?
  3. rpm -V openssh-server prints S.5....T. c /etc/ssh/sshd_config. What happened?
Search posts and bytes

Optional account

Keep your progress everywhere

Everything on AminBytes is free to read, with or without an account. Sign in only if you want your commits, streak and merged topics saved, on every device.

or

We keep only your name, avatar and which bytes you finished, and you can delete it all anytime. Privacy