Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
rpm and yum/dnfThis guide consolidates the core concepts and practical skills for managing software packages on Red Hat Enterprise Linux (RHEL) using both the low-level rpm and high-level yum (or dnf) tools.
Objective: To master the installation, removal, querying, and management of software packages on Red Hat Enterprise Linux (RHEL) using both low-level (rpm) and high-level (yum/dnf) tools.
Key Knowledge Areas:
rpm for direct package manipulation and queries.yum (and its successor, dnf) for repository-based package management.Think of a Linux software package as a meticulously organized box delivered to your house.
nano)..rpm (Red Hat Package Manager).A Package Manager is the tool that opens the box, reads the slip, puts everything in the right place, and handles the paperwork.
rpmThe rpm command is the fundamental tool for handling .rpm files directly. It is powerful but has a critical limitation.
Key Limitation: rpm does not automatically resolve dependencies. If you try to install a package that requires another package, rpm will fail until you manually find and install all required dependencies first. This can lead to a frustrating “dependency hell.”
rpm Commands for RHCSA| Command | Description | Use Case & Example |
|---|---|---|
| Install | Installs a package from a local .rpm file. | sudo rpm -ivh nano-2.9.8-1.el8.x86_64.rpm-i: install-v: verbose-h: show progress hash marks |
| Upgrade | Upgrades a package if installed; installs it if not. | sudo rpm -Uvh nano-2.9.8-1.el8.x86_64.rpm |
| Erase/Remove | Removes an installed package. | sudo rpm -e nano |
| Query | Checks if a package is installed. | rpm -q nano |
| Query Info | Displays detailed package information. | rpm -qi nano |
| Query List | Lists all files installed by a package. (Crucial for troubleshooting) | rpm -ql nano |
| Verify | Verifies the integrity of package files. Checks for changes, deletions, or permission modifications. | rpm -V nano |
Exam Tip:
rpm when you are given a specific .rpm file to install or when you need to query/verify what is installed on the system. yum.yum (and dnf)To solve the dependency problem, Red Hat introduced yum (Yellowdog Updater, Modified). yum is a high-level wrapper around rpm that works with online repositories.
Key Advantage:
yum automatically resolves, downloads, and installs all dependencies for you.A Note on yum vs. dnf:
dnf is the next-generation version of yum. It is the default package manager in RHEL 8 and 9.yum and dnf are functionally equivalent. The commands are the same (e.g., yum install works, but it’s actually a link to dnf). You can use either command.yum/dnf Commands for RHCSA| Command | Description | Example |
|---|---|---|
| Install | Installs a package and its dependencies from a repository. | sudo yum install wget |
| Remove | Removes a package and any dependencies that are no longer needed. | sudo yum remove wget |
| Update | Updates all system packages to their latest versions. (A critical task!) | sudo yum update |
| Update (specific) | Updates a single package. | sudo yum update nano |
| Search | Searches repository metadata for a package. | yum search "text editor" |
| List Installed | Checks if a specific package is installed. | yum list installed wget |
| Info | Shows detailed information about a package (from the repository). | yum info wget |
| Provides | Finds which package provides a specific file. (Extremely useful!) | yum provides /etc/passwd |
| History | Views a log of past yum transactions. Allows for undo/rollback. | sudo yum historysudo yum history undo 15 |
Repositories (“repos”) are centralized online storage locations that hold thousands of .rpm packages and their metadata.
.repo files in the /etc/yum.repos.d/ directory. Each file tells yum the repository’s name, base URL, and whether it is enabled.Key Repository Command:
yum repolist all
rpm vs. yum/dnf| Scenario | Recommended Tool | Reason |
|---|---|---|
Installing from a downloaded .rpm file | rpm -ivh | Direct file manipulation. |
| Installing software by name from the internet | yum install | Automatic dependency resolution. |
| Checking which files belong to a package | rpm -ql | Fast, low-level query. |
| Updating the entire system | yum update | Safely handles all dependencies. |
| Working on a system with no internet access | rpm | You must use locally stored packages. |
| Deep troubleshooting (e.g., verifying file integrity) | rpm -V | Direct access to the package database. |
yum for Package Discovery and InstallationObjective: To demonstrate the practical use of yum for searching, inspecting, and installing software packages, which is a critical skill for the RHCSA exam.
Key Skills Demonstrated:
yum search.yum info.yum install.All package management in a server environment is done via the command line. The Terminal is your primary interface.
yum --helpBefore using any command, knowing how to access its built-in help is a fundamental sysadmin skill.
install: Installs a package and its dependencies.remove: Removes a package and any now-unneeded dependencies.update: Updates all packages or a specified one.search: Searches package names and descriptions for a keyword.info: Displays detailed information about a package.provides: Finds which package owns a specific file.list: Lists packages based on criteria (e.g., list installed).Exam Tip: If you forget a specific
yumoption during the exam,--helpis your fastest and most reliable resource.
yum searchYou often know the function you need but not the exact package name. yum search is your tool for discovery.
yum search nano
nano.No matches found.yum infoAlways inspect a package before installation. This is a best practice to avoid installing the wrong software.
yum info nano
nano).5.6.1). Critical for troubleshooting and compliance.x86_64).2.7 M). Important for systems with limited resources.appstream). Helps verify the source is trusted.Exam Tip: Use
yum infoto confirm you are about to install the correct package and to note its version.
yum installThis is the final step where the software is actually deployed to the system.
yum install nano
yum is intelligent. It checks the local database first and will not reinstall a package unnecessarily.nano were not installed, yum would:
Is this ok [y/N]:y and press Enter to proceed. The installation will then run automatically.yum Handles Dependencies Automatically: Unlike rpm, you do not need to manually find and install dependencies. yum resolves, downloads, and installs them all.yum install command will always prompt you before making changes. This is your last chance to abort if you see unexpected packages.yum search returns nothing, you should be able to diagnose the potential causes (wrong name, missing repo).By mastering this yum workflow, you ensure that you can efficiently and correctly manage software on a RHEL system, a core competency for the RHCSA exam.
rpm CommandObjective: To demonstrate the practical use of the low-level rpm command for querying, verifying, and installing software packages. This is a critical skill for the RHCSA exam, especially for scenarios involving offline packages and deep system inspection.
Key Skills Demonstrated:
rpm HelpThe rpm command is extensive. Knowing how to access its help is the first step to using it effectively.
-q, --query: The foundation for all query operations.-i: Display package information (used with -q).-l: List files in a package (used with -q).-f, --file: Query the package that owns a file.-V, --verify: Verify the integrity of package files.-i, --install: Install a package.-U, --upgrade: Upgrade a package.-e, --erase: Remove (erase) a package.Exam Tip:
rpm --helpgives a concise overview. For exhaustive detail, use the man page:man rpm.
rpm -q)This is the most basic check to see if a package is installed.
rpm -q nano
nano-5.6.1-7.el9.x86_64
nano (package name), 5.6.1 (version), 7.el9 (release for RHEL 9), x86_64 (architecture).package nano is not installedrpm -qi)This provides a “birth certificate” for an installed package, which is invaluable for auditing and troubleshooting.
rpm -qi nano
Applications/Editors).RSA/SHA256 signature and Key ID verify that the package is a trusted, unaltered binary from Red Hat. This ensures security and integrity.rpm -ql)This answers the question: “What files did this package actually put on my system?”
rpm -ql nano
nano, including:
/usr/bin/nano/etc/nanorc/usr/share/doc/nano/..., man pages.rpm -V)This is a powerful troubleshooting command that checks if files from an installed package have been changed from their original state.
rpm -V nano
S – File size differsM – Mode (permissions) differ5 – MD5 checksum differs (the content was modified)U – User ownership differsG – Group ownership differsmissing – The file is missing.Exam Scenario: You are told a critical application is failing. Using
rpm -V [package-name]can quickly tell you if its core binaries or config files have been accidentally altered or deleted.
rpm -qf)This is the reverse of rpm -ql. It answers: “Which package does this file belong to?”
rpm -qf /usr/bin/nano
nano-5.6.1-7.el9.x86_64/usr/bin/wget) and want to install the package that provides it. rpm -qf tells you the package name is wget. You can then install it with yum install wget.rpm (rpm -ivh)This demonstrates the manual installation process and its critical caveat.
sudo rpm -ivh nano-5.6.1-7.el9.x86_64.rpm
nano required a library called libmagic, the command would fail with an error like:texterror: Failed dependencies: libmagic.so.1()(64bit) is needed by nano-5.6.1-7.el9.x86_64You would then have to manually find the libmagic package, install it, and repeat for its dependencies—a tedious and error-prone process.rpm is for Inspection and Offline Installs: Its primary strength is querying the package database (-q) and verifying the system (-V, -qf). Use it for installation (-i) only when you have a local .rpm file and are prepared to handle dependencies manually.yum/dnf is for Installation: For almost all installation tasks, use yum install. It automatically resolves dependencies from repositories.rpm -V is a powerful, often-overlooked tool. Know how to use it to diagnose system issues.yum is a high-level tool that uses rpm underneath. When yum installs a package, it ultimately calls rpm to perform the installation after resolving dependencies.By mastering these rpm commands, you demonstrate a deep understanding of how the RHEL package management system works, which is essential for passing the RHCSA exam and for effective system administration.
yumObjective: To demonstrate the practical use of yum for checking, applying, and auditing system updates. Keeping a system updated is a fundamental administrative task and is critical for the RHCSA exam.
Key Skills Demonstrated:
yum check-update)This is a “dry run” that scans all configured repositories to see what package updates are available without making any changes to the system.
sudo yum check-update
kernel-5.14.0-284.el9.x86_64 -> kernel-5.14.0-305.el9.x86_64).0 for no updates, 100 for updates available, and other codes for errors.Exam Tip: Use
yum check-updateto quickly assess the update state of a system without committing to an installation.
yum update -y)This is the primary command for keeping a RHEL system current. It resolves dependencies, downloads all available updates, and installs them.
sudo yum update -y
update: The action to upgrade all installed packages to their latest available versions.-y: The “yes” flag. This automatically confirms the transaction prompt. Use with caution in production, but it’s essential for the exam to avoid manual input.yum calculates the transaction: which packages will be updated, installed, or obsoleted.-y flag, asks Is this ok [y/N]:.Exam Tip: If an exam task says “update the system,”
sudo yum update -yis the command to use. Be prepared that a kernel update might be part of it.
yum upgrade -y)In modern RHEL (versions 7+), yum update and yum upgrade are functionally identical. Historically, upgrade was more aggressive about removing obsolete packages. For the RHCSA, you can treat them as the same.
sudo yum upgrade -y
yum update. For the exam, if the task says “upgrade,” using upgrade is safe, but update will achieve the same result.yum update <package_name>)You often need to update a single application without updating the entire system.
sudo yum update bash
Nothing to do. Complete!. If an update is available, yum will perform the update for bash and only its dependencies, not every package on the system.yum update --security)This is a critical command for maintaining system security. It filters available updates to install only those that fix security vulnerabilities.
sudo yum update –security
yum history)This is your system’s “flight recorder.” It provides a complete audit trail of all yum transactions, which is invaluable for troubleshooting.
sudo yum history
update, install nano).sudo yum history info <ID>: Shows detailed information about a specific transaction, including all packages that were changed.sudo yum history undo <ID>: This is a lifesaver. It attempts to reverse the transaction with the given ID. For example, if an update broke an application, you can undo it to revert to the previous state.Exam Tip: If you make a mistake during the exam (e.g., remove the wrong package),
yum historyandyum history undoare your best friends for recovery.
sudo yum update -y is the workhorse for updating the entire system.check-update vs. update: Use the first to see what’s available; use the second to actually perform the update.yum update kernel).yum update --security.yum history is not just for logging; it’s a powerful troubleshooting and recovery tool. You must be comfortable using it to inspect past actions and undo them if necessary.yumObjective: To demonstrate the complete lifecycle of a software package using yum, from installation and verification to removal. This is a fundamental, hands-on skill required for the RHCSA exam.
Key Skills Demonstrated:
yum install.rpm and yum history.yum remove.yum install)The yum install command is the standard method for adding software from configured repositories. Its key advantage is automatic dependency resolution.
sudo yum install httpd
yum calculates that httpd requires other packages to function. It doesn’t just install one package; it installs 11 in this case.yum presents a summary:
Is this ok [y/N]: is a critical safety check. You must type y and press Enter to proceed.Complete! message indicates a successful installation.Exam Tip: Always read the transaction summary. It ensures you are not accidentally installing unwanted or conflicting packages.
After any installation or removal, verification is a crucial step.
Method 1: rpm -q (Direct Query): rpm -q httpd
Method 2: yum history (Audit Trail): sudo yum history
Install and the command install httpd.ID 2), which allows you to investigate further or even undo the action.yum remove)The yum remove command cleanly uninstalls a package and any dependencies that are no longer needed by other software.
sudo yum remove httpd
yum shows the packages that will be removed. Notice they are often highlighted in red, providing a clear visual warning.y. This prevents accidental removal of critical software.yum intelligently removes the specified package and any dependencies that were installed with it and are not required by other packages.Complete! message confirms successful removal.The final step is to confirm the package is truly gone.
rpm -q httpd
package httpd is not installedyum handles dependencies automatically in both installation and removal. This is the primary reason to use it over rpm for these tasks.Is this ok [y/N] prompt is your last chance to abort. On the exam, you must type y to proceed.rpm -q for a quick check and yum history for a detailed audit log. The exam may ask you to verify your work, and this is how you do it.yum history is your safety net. If you accidentally remove the wrong package during the exam, you can use sudo yum history undo <ID> to revert the transaction, where <ID> is the transaction number from the yum history list.rpmObjective: To demonstrate the process and, more importantly, the practical limitations of using the low-level rpm command for package installation. This highlights why yum/dnf is the preferred tool and clarifies the exam expectations.
Key Skills Demonstrated:
.rpm file using dnf download.rpm -ivh.yum install).dnf download)Since rpm works with local files, the first step is to acquire the .rpm file.
dnf download httpd
httpd-2.4.62-4.el9.x86_64.rpm file from the enabled repositories and places it in your current working directory. It does not install the package.rpm -ivh)This step demonstrates the core weakness of using rpm for installation.
sudo rpm -ivh httpd-2.4.62-4.el9.x86_64.rpm
-i: Install-v: Verbose (shows details)-h: Print hash marks (#####) as a progress bar.httpd package is a meta-package that relies on other packages (like httpd-core) to function. The rpm command sees that these required packages are not installed and aborts the entire operation. It will not proceed until you manually find, download, and install every single dependency, which can lead to a “dependency hell.”yum install)The demo correctly pivots to using the high-level tool to solve the problem rpm cannot.
sudo yum install httpd
yum does not rely on a local file. It:
httpd package.rpm internally to install all components in the correct order.After the installation is complete, the local .rpm file is no longer needed.
rm httpd-2.4.62-4.el9.x86_64.rpm
ls to confirm the file has been deleted.rpm -ivh is for Local Files, Not Package Names: You cannot run rpm -ivh httpd. You must have the local .rpm file first. Use dnf download to get it.rpm Does Not Resolve Dependencies: This is the single most important point. The rpm command is a low-level tool that installs only what you tell it to install. It will fail if any prerequisites are missing.yum/dnf is the Solution to Dependency Hell: The primary role of yum is to be a dependency resolver. It finds and installs all required packages automatically.rpm for Installation on the Exam:
.rpm file path (e.g., Install the package from /tmp/mypackage.rpm).yum install: For 99% of tasks, if you are asked to “install a package,” the intended method is yum install [package_name].rpm vs. yum for Installation| Scenario | Command | Handles Dependencies? | Use Case |
|---|---|---|---|
| Install from repositories | sudo yum install httpd | Yes | Default, recommended method |
Install a local .rpm file | sudo rpm -ivh package.rpm | No | Manual installs; offline environments |
Download a local .rpm file | dnf download httpd | N/A | Preparing for a manual rpm installation |
Objective: To demonstrate the process of creating a local YUM repository by mounting an ISO image and configuring the system to use it as a software source. This is a critical skill for managing systems in isolated environments without internet access.
Key Skills Demonstrated:
The foundation of a local repository is the package source. For RHEL, this is typically the installation ISO.
rhel7.iso (or the equivalent for your RHEL version). This file contains all the packages in the Packages/ directory and the necessary metadata (repodata/)./root/rhel7.iso in this case).A mount point is simply an empty directory that will act as an access point for the contents of the ISO.
sudo mkdir -p /mnt/rhelmkdir: Creates a directory.-p: Creates parent directories if they don’t exist. This ensures /mnt is created if needed./mnt/rhel: A standard, descriptive location for a temporary filesystem mount.This step makes the contents of the ISO file accessible to the system as if it were a physical DVD-ROM.
sudo mount -o loop /root/rhel7.iso /mnt/rhelmount: The command to attach a filesystem.-o loop: Treats the regular file (rhel7.iso) as a block device (like a CD-ROM)./root/rhel7.iso: The source file./mnt/rhel: The target mount point.WARNING: ... read-only. This is normal. ISO filesystems are inherently read-only.This is the core of the setup. It tells yum where to find the local repository.
/etc/yum.repos.d/local.repo/etc/yum.repos.d/local.repo
yum reads all files with the .repo extension in this directory.sudo nano /etc/yum.repos.d/local.repo[LocalRepo]: A unique ID for the repository. This is what yum commands will reference.name: A human-readable description.baseurl=file:///mnt/rhel: Crucial. This specifies the location using the file:// protocol, pointing to our mount point. Note the three slashes (file:///).enabled=1: Tells yum this repository is active.gpgcheck=0: Disables GPG signature checking. In a production environment, this is a security risk. It’s used here for simplicity. The best practice is to set gpgcheck=1 and import the Red Hat GPG key with rpm --import /mnt/rhel/RPM-GPG-KEY-redhat-release.[LocalRepo]:
name: CentOS RHEL 9.6 - BASEOS
baseurl=file:///mnt/rhel:
enabled=1
gpgcheck=0CentOS-Stream-BaseOS.repo
[baseos]
name=CentOS Stream 10 - BaseOS
baseurl=https://mirror.stream.centos.org/10-stream/BaseOS/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
sslverify=0
Always verify your setup to ensure yum can see and use the new repository.
loop device with its mount point listed as /mnt/rhel.LocalRepo in the output. If it appears, the configuration is successful.mkdir -p /mnt/rhelmount -o loop /path/to/iso /mnt/rhel.repo file in /etc/yum.repos.d/ with the correct baseurl.yum repolist to confirm.baseurl: The file:/// protocol and the absolute path to the mount point are critical. A single typo here will cause the repository to fail.gpgcheck=0 does. While used here for simplicity, be prepared to import a GPG key if required by an exam question./etc/fstab. For a one-time exam task, this is likely not required, but understanding the concept is valuable.