Introduction
In the previous content, we have become familiar with the command line, file system, and permission system. In this article, we will move on to another extremely important capability—installing, updating, and managing software in Linux.
If the command line is the “language of controlling the system,” then package management is the “toolbox for building system capabilities.”
This article will systematically introduce you to the most commonly used package management tools in Linux: RPM, YUM, and DNF. These are core components of distributions such as Red Hat, CentOS, Rocky, and Fedora.
1. Introduction to Linux Packages
In a Linux system, software cannot simply be copied over to be used. To facilitate management and installation, the system packages software into a specific format—what we refer to as a package.
Packages typically include:
- Program files
- Configuration files
- Dependency information
- Installation scripts / Uninstallation scripts
Different Linux distributions have different package formats:
| Distribution | Package Format | Package Manager |
|---|---|---|
| Red Hat / CentOS / Rocky / Fedora | <span>.rpm</span> |
rpm / yum / dnf |
| Debian / Ubuntu | <span>.deb</span> |
dpkg / apt |
In this article, we will focus on the RPM series (RHEL family).
2. Introduction to RPM Packages
RPM (RedHat Package Manager) is the underlying package format and basic management tool for RedHat series systems.
A typical RPM package name looks like:
nginx-1.20.1-9.el9.x86_64.rpm
It can be broken down into:
| Name Part | Meaning |
|---|---|
| nginx | Software name |
| 1.20.1 | Version |
| 9 | Release number |
| el9 | For CentOS/RHEL 9 |
| x86_64 | Applicable CPU architecture |
The advantages of RPM include:
- Fast installation speed
- Strong verification (can check integrity)
- Does not rely on online repositories, can be installed offline
However, the drawbacks are also evident:
👉 Does not resolve dependencies (for example, installing one software may require 50 dependencies)
Therefore, YUM and DNF were later developed.
3. RPM Commands and Common Options
Common functions of RPM include:
- Installing software
- Uninstalling software
- Querying software information
- Checking software integrity
1. Install RPM Package
rpm -ivh package.rpm
| Option | Meaning |
|---|---|
| -i | install |
| -v | verbose, output detailed information |
| -h | hash, display installation progress with # |
2. Upgrade Software
rpm -Uvh package.rpm
3. Uninstall Software
rpm -e package_name
Note: It is not the .rpm file name, but the package name, for example:
rpm -e nginx
4. Check if Software is Installed
rpm -q package_name
Example:
rpm -q bash
5. Query Files Included in Software
rpm -ql package_name
6. Query Which Package a File Belongs To
rpm -qf /usr/bin/passwd
Practical Case: Using RPM to Install Local Packages
Assuming we have downloaded a local nginx.rpm file and are preparing for offline installation.
# Install local RPM package
rpm -ivh nginx.rpm # -i install, -v show details, -h show progress bar
# Check if installation was successful
rpm -q nginx
# View which files were installed by the nginx package
rpm -ql nginx
# Uninstall nginx
rpm -e nginx
This type of operation is common in enterprise servers, such as installing software in offline environments, creating internal network installation packages, etc.
4. Basic Concepts of YUM and DNF
Since RPM cannot automatically handle dependencies, YUM and DNF were developed.
✔ YUM (Yellowdog Updater Modified)
- Default manager used in RHEL/CentOS 7 and below
- Can handle dependencies
- Supports online repositories
- Supports automatic updates
✔ DNF (Dandified Yum)
- Default manager starting from RHEL / CentOS / Fedora 8+
- Is an upgraded alternative to YUM
- Better performance / more intelligent dependency resolution
- Command format is almost fully compatible with YUM
5. YUM and DNF Commands
The following commands are common to both YUM and DNF:
1. Install Software
dnf install nginx
2. Uninstall Software
dnf remove nginx
3. Update All Packages
dnf update -y
4. Search for Packages
dnf search nginx
5. View Package Information
dnf info nginx
6. Clean Cache
dnf clean all
Practical Case: Using DNF to Install and Manage
dnf install nginx -y # Install nginx (-y auto-confirm)
dnf info nginx # View nginx package information
dnf remove nginx # Uninstall nginx
dnf clean all # Clean cache
This is the most mainstream method for installing commonly used software on enterprise servers, and it is highly recommended that readers become proficient in it.
6. Basic Concepts of Linux Software Repositories
A software repository (Repository, abbreviated as repo) is a “server” that holds a large number of packages.
DNF/YUM will automatically download the required dependencies from the repository.
Common repositories include:
- Official repositories (RedHat/Fedora/CentOS)
- EPEL repository (Extra Packages for Enterprise Linux)
- Private internal repositories (commonly used by enterprises)
- Third-party repositories (e.g., official nginx repository)
Repository configuration files are usually located at:
/etc/yum.repos.d/
A typical repository configuration file <span>example.repo</span> looks like:
[example]
name=Example Repo
baseurl=https://example.repo/linux
enabled=1
gpgcheck=1
Conclusion
In this article, we have introduced from the basics of software management to advanced topics:
- What RPM packages are
- How to use RPM to manage software
- Why YUM and DNF are needed
- Common commands for YUM/DNF
- The basic structure and function of software repositories
By mastering these tools, you will be able to easily install, uninstall, and upgrade software in the Linux system, enhancing the system’s capabilities.