Menu
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.”
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:
rpmis the low-level tool. It installs, removes, queries and verifies.rpmfiles and keeps the package database. It doesn’t download anything or resolve dependencies.yum(and its successordnf) on the Red Hat family, andzypperon SUSE, download from repositories, resolve dependencies, and userpmunderneath.
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#
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 nameA 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#
| Command | What it does |
|---|---|
rpm -ivh file.rpm | Install. Fails if any version is already installed. |
rpm -Uvh file.rpm | Upgrade, or install if it isn’t there. The usual choice. |
rpm -Fvh file.rpm | Freshen: upgrade only if an older version is installed |
rpm -e package | Erase (remove) an installed package |
rpm --reinstall -vh file.rpm | Reinstall 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.
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.rpmVerifying... ################################# [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:
| Command | Shows |
|---|---|
rpm -q tree | Is it installed? Which version? |
rpm -qa | All installed packages (rpm -qa 'kernel*' filters, --last sorts by install date) |
rpm -qi tree | Info: version, vendor, build date, signature, description |
rpm -ql tree | List of files in the package |
rpm -qc tree / rpm -qd tree | Only its config files / documentation |
rpm -qf /usr/bin/tree | Which package owns this file |
rpm -qR tree | What it requires (dependencies) |
rpm -q --whatrequires bash | Which installed packages need this capability |
rpm -q --whatprovides libc.so.6 | Which installed package provides a capability |
rpm -q --changelog tree / --scripts | Package history / install and removal scripts |
rpm -qpi file.rpm, rpm -qpl file.rpm | The same queries on a package file (-p) instead of the database |
rpm -qf /usr/bin/tree
rpm -qi tree | head -6tree-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 : Unspecifiedrpm: 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.
sudo rpm -V openssh-serverS.5....T. c /etc/ssh/sshd_configEach position is a test; a dot means it passed:
| Code | Meaning | Code | Meaning |
|---|---|---|---|
S | Size differs | L | Symlink target differs |
M | Mode (permissions or type) differs | U | User owner differs |
5 | Checksum (digest) differs | G | Group owner differs |
D | Device number differs | T | Modification time differs |
P | Capabilities differ | missing | The 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/:
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)tree-1.8.0-10.el9.x86_64.rpm: digests signatures OKWithout 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:
mkdir /tmp/x && cd /tmp/x
rpm2cpio ~/tree-1.8.0-10.el9.x86_64.rpm | cpio -idmv./usr/bin/tree
./usr/share/doc/tree/README
./usr/share/licenses/tree/LICENSE
./usr/share/man/man1/tree.1.gz
226 blockscpio -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.
| Command | What it does |
|---|---|
yum install tree | Install with dependencies (yum install ./file.rpm for a local file) |
yum reinstall tree | Reinstall the same version |
yum remove tree | Remove (erase is an old alias) |
yum update / yum upgrade | Upgrade everything, or just the packages you name |
yum check-update | List available updates without installing |
yum search word | Search names and summaries |
yum info tree | Details about a package, installed or not |
yum list installed / yum list available | Installed / installable packages |
yum provides /usr/bin/dig | Which package (installed or not) has this file. Also whatprovides. |
yum repolist | Enabled repositories |
yum history / yum history undo 5 | Past transactions, and undoing one |
yum clean all | Delete cached metadata and packages |
yum group list / yum group install "Development Tools" | Package groups |
yumdownloader tree / dnf download tree | Download the .rpm without installing |
dnf provides /usr/bin/digbind-utils-32:9.16.23-24.el9_5.x86_64 : Utilities for querying DNS name servers
Repo : appstream
Matched from:
Filename : /usr/bin/digFor 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:
1[main]
2gpgcheck=1
3installonly_limit=3
4clean_requirements_on_remove=True
5best=True
6skip_if_unavailable=Falsegpgcheck=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:
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:
| Command | Short | What it does |
|---|---|---|
zypper refresh | ref | Refresh repository metadata |
zypper install tree | in | Install (in -f or --force reinstalls) |
zypper remove tree | rm | Remove |
zypper update | up | Update installed packages |
zypper dist-upgrade | dup | Upgrade the whole distribution (openSUSE Tumbleweed, release upgrades) |
zypper list-updates | lu | Show available updates |
zypper search tree | se | Search (se -i for installed only) |
zypper info tree | if | Package details |
zypper what-provides /usr/bin/tree | wp | Which package has a file or capability (same as se --provides) |
zypper repos | lr | List repositories |
zypper addrepo URL alias | ar | Add 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#
rpmhandles local files, no dependency resolution.yum/dnfandzypperresolve 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:Ssize,Mmode,5checksum,Ttime,cconfig file. Check signatures withrpm -K/--checksig, add keys withrpm --import. rpm2cpio file.rpm | cpio -idmvextracts files without installing.yum/dnf:install,reinstall,remove,update,check-update,search,info,list,provides,repolist,clean all.dnfreplacedyum(RHEL 8+, Fedora).- Config:
/etc/yum.conf(/etc/dnf/dnf.conf), repositories as.repofiles in/etc/yum.repos.d/withbaseurl,enabled,gpgcheck,gpgkey. zypper:in,rm,up,dup,se,if,ref,lr,ar,wp. Repos in/etc/zypp/repos.d/.
Answer these 3 questions to commit this byte to your learning path.
Reset. This byte isn't committed any more. Answer the questions again to commit it.
$ git commit -m "learn(lpic-102): Use RPM and YUM package management"
[main d6977db] learn(lpic-102): Use RPM and YUM package management
1 byte changed, 3 insertions(+)
See it on your path Already committed . Try the questions again any time, it won't undo anything. To uncommit it and start over: