π§° Linux/Unix: RHEL-Based Package Management β yum
, dnf
, rpm
Explained with Examples
π§² Introduction β Why Learn RHEL-Based Package Managers?
If youβre working with Red Hat Enterprise Linux (RHEL), CentOS, Rocky Linux, or Fedora, youβll manage software using yum
, dnf
, and rpm
. These tools help install, update, and troubleshoot packages using .rpm
files and repositories.
π― In this guide, youβll learn:
- How to manage software with
yum
,dnf
, andrpm
- Key differences and use cases for each tool
- Real command-line examples and practical tips
π½οΈ 1. yum
β Yellowdog Updater, Modified
β
What is yum
?
yum
is a high-level package manager used in RHEL-based systems to install, remove, and update software. It handles dependencies and works with online or local repositories.
π οΈ Syntax:
sudo yum [command] [package]
πΉ Common yum
Commands:
Command | Description |
---|---|
install | Install a package |
remove | Remove a package |
update | Update all packages |
search | Search for a package |
info | Show package details |
list installed | List all installed packages |
π§ͺ Example:
sudo yum install httpd
π€ Output:
Installed:
httpd.x86_64 0:2.4.6-97.el7.centos
β Update all packages:
sudo yum update
βοΈ 2. dnf
β Dandified Yum (Modern Replacement)
β
What is dnf
?
dnf
is the modern replacement for yum
, available in Fedora and RHEL 8+. It offers better performance, dependency handling, and transaction history.
π οΈ Syntax:
sudo dnf [command] [package]
πΉ Common dnf
Commands:
Command | Description |
---|---|
install | Install packages with dependencies |
remove | Remove packages |
upgrade | Update all system packages |
search | Search available packages |
info | Show detailed package info |
history | View transaction history |
π§ͺ Example:
sudo dnf install vim
π€ Output:
Installed:
vim-enhanced-2:8.0.1763-19.el8.x86_64
β View install/remove history:
dnf history
π¦ 3. rpm
β Red Hat Package Manager (Low-Level)
β
What is rpm
?
rpm
is the low-level tool for installing .rpm
files directly. It doesn’t resolve dependencies automatically.
π οΈ Syntax:
sudo rpm [option] package.rpm
πΉ Common rpm
Commands:
Command | Description |
---|---|
-i | Install a package |
-U | Upgrade a package |
-e | Erase/remove a package |
-q | Query installed package |
-ql | List files of a package |
-qf [file] | Find which package owns a file |
π§ͺ Example 1: Install .rpm
package
sudo rpm -ivh google-chrome.rpm
π€ Output:
Preparing... #################################
Updating / installing...
1:google-chrome-stable #################################
π§ͺ Example 2: Check if a package is installed
rpm -q wget
π§ If dependencies are missing:
sudo yum install -y --skip-broken
π§ Tool Comparison: yum
vs dnf
vs rpm
Feature | yum | dnf | rpm |
---|---|---|---|
Dependency resolution | β | β | β |
Repository usage | β | β | β (local files only) |
Speed & performance | Medium | Faster | Fast (local) |
Script-friendly | β | β | β |
Recommended use | Legacy systems | Modern RHEL & Fedora | Manual package install |
π Summary β Recap & Next Steps
For RHEL-based distributions, mastering yum
, dnf
, and rpm
lets you confidently manage packages, perform updates, and install offline software. Use yum/dnf
for regular tasks and rpm
for low-level control.
π Key Takeaways:
- Use
yum
ordnf
for automatic dependency management. - Use
dnf
on newer systems (RHEL 8+, Fedora). - Use
rpm
for manual.rpm
installs or queries.
β FAQs
β Whatβs the difference between yum
and dnf
?
β
dnf
is a modern replacement for yum
, offering better performance, rollback, and modular support.
β Can I still use yum
on RHEL 8?
β
Yes, but it’s a symlink to dnf
internally.
β How do I fix a broken rpm
install?
β
Use:
sudo yum install -f
β How do I list all .rpm
packages installed?
β
Run:
rpm -qa
β Can I uninstall a package installed with rpm
using dnf
?
β
Yes. All managers interface with the same underlying RPM database.
Share Now :