102.5 Use RPM and YUM package management¶
Introduction¶
RedHat Package Manager (RPM) and YellowDog Updater Modified (YUM) are used by Fedora, Red Hat, RHEL, CentOS, and others to manage packages. The package format is .rpm, managed at the low level by the rpm tool and at the high level by yum (or dnf/zypper) for repository-based operations.
Package management layers (same idea as Debian, different tools):
Debian side Red Hat side
────────── ──────────
apt-get / apt-cache yum / dnf / zypper (high-level: repos, dependencies)
| |
v v
dpkg rpm (low-level: individual packages)
| |
v v
.deb files .rpm files
yum¶
yum is the high-level package manager for Red Hat-based systems. Its configuration lives at:
/etc/yum.conf- main config (cache directory, log file, GPG check settings)/etc/yum.repos.d/- one.repofile per repository
Sample /etc/yum.conf:
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
Sample repo file /etc/yum.repos.d/fedora.repo:
[fedora]
name=Fedora $releasever - $basearch
#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch
enabled=1
countme=1
metadata_expire=7d
repo_gpgcheck=0
type=rpm
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
Key fields in a .repo file:
| Field | Meaning |
|---|---|
name |
Human-readable name of the repo |
baseurl or metalink |
Where to download packages from |
enabled=1 or enabled=0 |
Whether this repo is active |
gpgcheck=1 |
Verify package signatures before installing |
gpgkey |
Path to the GPG key used for signature verification |
Usage: yum [OPTIONS] [COMMAND] [PACKAGE_NAME]
The most important option is -y, which answers yes to all confirmation prompts automatically.
| Command | Description |
|---|---|
install |
Install a package (resolves dependencies automatically) |
reinstall |
Reinstall a package |
remove |
Remove an installed package |
update |
Update repository info and update named packages, or all if none named |
upgrade |
Like update but also removes obsolete packages |
check-update |
Check if updates are available without installing |
search |
Search repositories by package name or description |
info |
Show detailed information about a package |
list |
Show a list of packages (installed, available, or both) |
provides |
Find which package provides a specific file. E.g. yum provides /etc/hosts tells you setup owns it |
deplist |
Show dependencies of a package |
localinstall |
Install from a local .rpm file (resolves dependencies from repos) |
localupdate |
Update from a local .rpm file |
groupinstall |
Install a group of packages. E.g. yum groupinstall "KDE Plasma Workspaces" |
history |
Show history of yum usage |
You can also use wildcards:
Managing repositories:
yum repolist all # list all repos (enabled and disabled)
yum-config-manager --add-repo https://example.com/my.repo # add a new repo
yum-config-manager --disable updates # disable a repo
yum-config-manager --enable updates # re-enable a repo
yum clean packages # clear downloaded package cache
yum clean metadata # clear repository metadata cache
Fedora uses dnf as its package manager and will translate yum commands to dnf equivalents automatically.
yumdownloader¶
Downloads .rpm files from repositories without installing them. Use --resolve to also download all dependencies:
RPM¶
The rpm command works on individual .rpm files. Format: rpm ACTION [OPTION] package
Common option: -v for verbose output.
| Short | Long | Description |
|---|---|---|
-i |
--install |
Install a package |
-e |
--erase |
Remove a package |
-U |
--upgrade |
Install if new, upgrade if already installed (most common for installs) |
-q |
--query |
Check if a package is installed |
-F |
--freshen |
Upgrade only if the package is already installed (skip if not present) |
-V |
--verify |
Check the integrity of an installed package against its original state |
-K |
--checksig |
Check the integrity and signature of a .rpm file before installing |
rpm actions at a glance:
-i install (fresh only)
-U install OR upgrade (use this most of the time)
-F upgrade only if already present
-e erase/remove
-q query (is it installed?)
-V verify (is it intact?)
-K checksig (is the .rpm file valid?)
Install and update¶
In most cases, use -U (not -i), since it handles both fresh installs and upgrades:
rpm -Uvh package.rpm # -v verbose, -h shows hash progress bar (50 # signs)
rpm -Uvh *.rpm # install multiple rpms, resolving inter-dependencies among them
Override options (use with caution):
- --nodeps - skip dependency checking
- --force - force install despite any errors
Note: rpm does not track automatically-installed dependencies, so it cannot remove them later (unlike yum).
Query¶
Basic query:
rpm -q breezy # is breezy installed? shows name-version if yes
rpm -q emacs # "package emacs is not installed"
Query options (combine with -q):
| Short | Long | Description |
|---|---|---|
-a |
--all |
List all installed packages (rpm -qa) |
-c |
--configfiles |
Show only the package's config files |
-i |
--info |
Show detailed info (version, size, description) |
-l |
--list |
List all files a package installs |
-R |
--requires |
Show dependencies |
-f |
--file |
Which package owns this file? E.g. rpm -qf /usr/bin/unzip |
--whatprovides |
Which package provides this capability? |
Add -p to query an uninstalled .rpm file instead of the installed database:
rpm -qi unzip # info about installed unzip
rpm -qip atom.rpm # info about an uninstalled .rpm file
rpm -ql unzip # files installed by unzip
rpm -qlp atom.rpm # files inside an uninstalled .rpm file
Verify¶
Check if an installed package's files have been modified since installation:
Each character in the output represents a specific check:
| Code | Meaning |
|---|---|
S |
Size differs |
M |
Mode (permissions/file type) differs |
5 |
MD5 digest differs (file content changed) |
D |
Device major/minor number mismatch |
L |
Symlink path mismatch |
U |
User ownership differs |
G |
Group ownership differs |
T |
Modification time differs |
P |
Capabilities differ |
Check the integrity and signature of an .rpm file (before installing):
This verifies the RSA/SHA256 signature and MD5/SHA digests to confirm the file hasn't been tampered with.
Uninstall¶
Notes:
- rpm removes without asking for confirmation (no Y/N prompt)
- rpm will refuse to remove a package that other packages depend on (shows error)
- To remove a package with dependents, remove the dependents first, or pass multiple package names to rpm -e
Extract RPM files¶
rpm2cpio¶
Convert an .rpm file to a cpio archive, then extract it. Useful when you need files from a package without actually installing it:
Or in one line:
Zypper¶
SUSE Linux and openSUSE use ZYpp as their package manager engine. The command-line tool is zypper. Commands can be shortened (e.g. zypper se instead of zypper search).
| Command | Description |
|---|---|
help |
General help |
install (or in) |
Install a package |
info |
Display info about a package |
list-updates |
Show available updates without installing |
lr |
Show repository information |
packages |
List all available packages, or filter by repo |
what-provides |
Show which package owns a file |
refresh |
Refresh repository metadata |
remove (or rm) |
Remove a package |
search (or se) |
Search for a package. -i for installed only, -u for uninstalled only |
update |
Update installed packages |
verify |
Check a package and its dependencies |
Managing repositories:
zypper addrepo URL ALIAS # add a repository
zypper removerepo ALIAS # remove a repository
zypper modifyrepo --enable ALIAS # enable a repo
zypper modifyrepo --disable ALIAS # disable a repo
Other tools¶
| Tool | Used by | Description |
|---|---|---|
dnf |
Fedora (default) | Fork of yum with improved performance. Most yum commands work identically. Pre-installed on Fedora. |
YaST |
SUSE | Graphical system administration tool including package management |
PackageKit |
KDE/GNOME desktops | Graphical package manager used by modern desktop environments |
dnf quick reference (same syntax as yum for most operations):
dnf search PATTERN # search
dnf info PACKAGE # package info
dnf install PACKAGE # install
dnf remove PACKAGE # remove
dnf upgrade PACKAGE # upgrade one package
dnf upgrade # upgrade everything
dnf provides FILENAME # which package provides this file?
dnf list --installed # all installed packages
dnf repoquery -l PACKAGE # list files inside a package
dnf repolist # list repos
dnf config-manager --add_repo URL # add a repo
dnf config-manager --set-enabled REPO # enable a repo
dnf config-manager --set-disabled REPO # disable a repo
Summary¶
I have a Red Hat-based Linux system where software is distributed as .rpm packages. Like Debian's two-layer system, there's rpm at the bottom (works on individual files, no dependency resolution) and yum/dnf/zypper on top (works with repositories, resolves dependencies automatically).
For rpm, the key actions are -U (install or upgrade, the most common), -e (erase/remove), -q (query with sub-options like -qa for all packages, -qf for file ownership, -ql for file listing), -V (verify installed files against original state), and -K (check .rpm file integrity before installing). The -p modifier switches queries from the installed database to an uninstalled .rpm file.
For yum/dnf, the commands mirror what apt-get does on Debian: install, remove, update, upgrade, search, info, provides. Repository config lives in /etc/yum.conf and /etc/yum.repos.d/. SUSE uses zypper instead, with shortened commands (se for search, in for install, rm for remove). rpm2cpio extracts files from a .rpm without installing, which is useful for pulling a single config file from a package during recovery.