Red Hat Package Manager is the default open source package management utility created under the General Public License (GPU). The package management system is for all Red Hat based Linux derivatives such as Fedora, RHEL, and CentOS. RPM provides system administrators with the five basic modes of package management operations: installing, updating, removing, querying, and verifying packages.
In addition, Yellowdog Updater Modified (YUM) is to RPM what the APT package management tool is to the dpkg utility in the Debian packaging system: it solves package dependency issues from RPM. In this guide, we will briefly introduce YUM. Whereas, we will have an in-depth introduction and background of the RPM packaging system for Red Hat Linux distributions.
early days of Linux, software/programs were included in the system by compiling the source code into executable binaries. They were sometimes compiled in the form of a package known as tarballs that contained multiple files. After installing the software from a tarball, all executable files, documents, configuration files, and libraries would be spread throughout the system in relevant directories.
However, this form of application inclusion has its limitations
: the user’s inability to find program documents and
- configuration files.
- Difficulty finding the required dependencies of the
- It requires the user to search for and delete each program file individually
- It did not contain metadata: therefore, after installation, users were unaware of the version of the program and other details.
Since then, Linux distributions have come a long way by providing software in complex pre-built programs known as packages. Therefore, all Linux distributions followed two main packaging formats, RPM and DEB. In this article, we focus on an RPM packaging system.
RPM, YUM and DEB package management systems (for Debian Linux distributions) have many similarities. All of them can update, install, remove, and update packages with a command-line function.
At the time of any Linux installation, a large section of packages is also installed, which is relevant to the intended use of the system. However, at some point, a user needs to add new packages for additional functionality, update current packages, or remove packages that are not needed on Red Hat-based systems.
Let’s find out how package managers for Red Hat Linux distributions perform the above tasks, including the challenges of finding package details or the commands contained in the packages.
The RPM Package Manager offers the main command called rpm that provides several options to allow the user to find all the information related to the package. The options offered by rpm are grouped into three main categories:
install, update, and
- remove packages
- to query package-related information and verify
- that they perform various functions
In this article, we will discuss the first two rpm command options. Although it can perform the basic tasks related to package management, being the first tool to deal with RPM packaging, rpm has some main limitations:
Package installation with rpm fails if package dependency is not available. In addition, it requires the user to find which package contains the component, which in turn has some dependencies. Additionally, rpm commands require the user to identify the location of the RPM file.
A convenient solution to the above issues is YUM which automates package update and management for RPM system. It also provides dependency management by considering RPM packages, not as individual software but as part of a repository system.
Packaging RPM package
is the combination of configuration files, commands, documents to provide a software function. It also contains metadata that contains package content, where it came from or was installed, version, and dependency details with other information.
Before we delve into the RPM package files, the package name itself shares a lot of details about the software. To find details of a package already installed within the system, use the rpm command with the query information option -qi:
The output of the above command shares details from where the program was downloaded, directly from the YUM repository or any installation media. Similarly, it also shares details along the lines of when the program was installed, who built it, its size, and when it was installed.
Software for Linux distributions comes from open source projects known as upstream software vendors. They make the software available with license conditions. Distributions build the source code into binaries and consolidate them with other relevant components into a package.
The consolidated RPM package is signed for integrity and added to the repository in correspondence with the distribution and architecture. All RPM packages come from the yum repositories available within a directory on the web server, a local machine directory or media such as CD or DVD or an FTP server.
The location of the repository files is available on the user’s system within the /etc/yum.repos.d/ directory, which is the default location for storing repository information. However, users can also find or specify these locations within the main YUM configuration file /etc/yum.conf.
A repository file contains multiple copies of distribution packages available from different locations, also known as mirrors. Therefore, it informs YUM about the nearest mirror location for the fastest download. The repository file has three sections, which contain information about the normal, debug, and finally source packages.
Like Debian packaging, RPM and YUM get details about installed packages from the local database. Package managers retrieve metadata (from the /var/cache/yum directory) about packages within the local database of enabled repositories.
Download RPMs from YUM Repository
To examine the contents of RPMs or install them in an environment that is not connected to the network, a user may need to download the package. It can be made possible with the help of the yumdownloader command. Use the yumdownloader command, with the name of the package to download it to the current directory. For example, download the vim text editor as follows:
Or, use the -resolve option to download the required dependencies for the
Although the rpm command can perform basic installation and updates, users use it only when the program files are already in the current directory and ready to install. Because vim is already available in the current directory, install it using the rpm command with a –i option with the fully qualified package name, as follows:
Use the –
U option to update the package with a -hv option to print the hash signs and detailed output. Note that the -U option installs the zsh package even when it is already installed.
The rpm command offers another type of installation with the -F (freshen) options that install a package only if an earlier version of that package exists. It is useful in a scenario where the user wants to update all RPMs installed in a current directory.
Users can add more options to any of the installation options, such as the -replacepkgs option that allows you to reinstall a package if a component of the package is removed by mistake. Similarly, the -oldpackage option allows installation of an earlier version of the package.
To remove RPM packages, use the -e option of the rpm command with only a base package name. The output of the following command shows that, unlike removing packages in the Debian packaging system, it does not show any removed dependencies in the process.
Note that, unlike installing the package, it is not requested before the removal of the package. But if the package is a dependency of another program, the user receives an error message since the rpm command cannot remove it.
this section, we will discuss several ways to query information through the rpm command. In the RPM packaging section, we learn how to display information about an already installed package through the -qi information. Similarly, the rpm command also allows the display of files, configuration files and other documentation with the help of -ql, –qc and –qd options, as follows:
RPM packages include a lot of information that can be retrieved with various indicators. For example, a user can use the -require option to find previous programs or files to install a common emac program.
Another important feature offered by rpm is an option —queryformat that allows us to consult information such as tags and output in any format that the user prefers. Run
the following command to display all available tags: For example, to display the name, size, and version number of the binutils tag,
use the following command: The package is binutils
its size is 31814958, and the version is 41.fc34
Finally, add the –p flag to the query option to help investigate RPMs shared by someone before installation.
This package contains all the common files needed by emacs, Emacs-lucid, or emacs-nox.
RPM Verification The RPM
database contains fingerprints for each package file that allows the user to verify its integrity. The rpm command provides a –V function to check for any changes made to the components of the installed package. However, it is important to note that changes take place in the configuration file after installation, but changes to binary files are a problem.
Install the emac-common package and make changes to your files. But remember to remove and reinstall the package after experimentation.
The above output shows the changes made to the /etc/ file, while the /etc/ file is deleted. The letters or numbers in the output above represent any changes made to the package files. These letters replace the dots after file manipulation, some of the indicators are as follows
: S: File size differs D: The
- major/minor number of the device does not match
- Q: Capabilities differ
- U: User property
- MD5 sum differs
- T: Modification
M: File mode differs
time More details about verification indicators can be found in the official documentation.
The above output helps interpret changes in file size, changes in md5sum against file fingerprint, and modification time. The rpm command provides a -replacepkgs option to restore the state of the package. Check again with the verification option: no output shows any changes.
The ideal practice is to keep a backup copy of the /var/lib/rpm database on read-only media. It helps to verify the integrity of the package with the assurance that it is not verified with a tempered/cracked database.
The article details the history and evolution of the packaging system for the Red Hat Linux distribution. It also provides details about RPM packaging and its location within the system. Finally, the article provides in-depth details on the five basic RPM operations.