The RPM (Red Hat Package Manager) command is a fundamental tool in the world of Linux package management. It is widely used in Red Hat-based distributions like Fedora and CentOS, as well as other RPM-based distributions. The RPM command allows users to install, query, verify, and manage software packages, making it an essential tool for system administrators and Linux enthusiasts. In this article, we will explore the various aspects of the RPM command, including its usage, common options, and real-world examples.
What is RPM?
RPM is a software package management system for installing, updating, and removing software packages on Linux-based systems. Red Hat originally developed it but has been adopted by many other Linux distributions. RPM packages, often denoted with the `.rpm`
file extension contains all the necessary files, metadata, and scripts required to install and manage software on a Linux system.
Basic Syntax of RPM in Linux
The basic syntax of the rpm command is as follows:
rpm [options] [package_name]
Here,
- [options] represent various command-line options that control the behavior of the rpm command.
- [package_name] refers to the name of the RPM package you want to work with.
Options Available in the `rpm` command in Linux
These options provide a wide range of functionalities and control when working with RPM packages on Linux systems. You can use them to install, upgrade, query, and manage packages effectively.
Options | Description |
---|
-i, --install | Install an RPM package. |
---|
-U, --upgrade | Upgrade an RPM package. |
---|
-q, --query | Query RPM package(s) or display information about installed packages. |
---|
-a, --all | Used with -q, lists all installed packages. |
---|
-V, --verify | Verify the integrity of installed packages. |
---|
-e, --erase | Uninstall or erase an RPM package |
---|
-F, --freshen | Upgrade packages but only if a package with the same name is already installed. |
---|
--nodes | Ignore package dependencies during installation or removal. |
---|
--test | Test mode; shows what the rpm command would do without making any changes. |
---|
-h, --hash | Display hash marks (#) to indicate progress during installation or removal. |
---|
--force | Force installation, even if it overwrites files from other packages or has other issues. |
---|
--reinstall | Reinstall an RPM package. |
---|
--import | Import a GPG key for package signature verification. |
---|
--resign | Resign an RPM package with a new GPG key. |
---|
-F, --file | Used with -q, queries which package owns a particular file. |
---|
--package | Used with -q, queries information about an RPM file or package. |
---|
--setperms | Set permissions of package files to their default values. |
---|
--setugids | Set user and group ownership of package files to their defaults. |
---|
--nodigest | Skip digest checks when installing or upgrading packages. |
---|
--rebuilddb | Rebuild the RPM database. |
---|
--testsig | Test the digital signature of an RPM package. |
---|
--showrc | Show RPM configuration settings. |
---|
-h, --help | Display help information. |
---|
--version | Display the RPM version. |
---|
Common RPM Commands and Options
1. Installing RPM Packages
To install an RPM package, you can use the `rpm`
a command followed by the `-i`
(or `--install`
) option and the name of the RPM package file. For example:
rpm -i package.rpm
This command installs the specified package on your system.
Here we are installing Jenkins.
rpm -i /root/jenkins-2.282-1.1.noarch.rpm
Installing Packages2. Upgrading RPM Packages
To upgrade an installed package with a newer version, use the `-U`
(or `--upgrade`
) option:
rpm -U package.rpm
This command will replace the older version of the package with the new one if it's already installed
Upgrading Packages3. To list all installed packages in RPM
To list all installed packages on your system, use the -q (or --query) option with the -a (or --all) flag:
rpm -qa
This will display a list of installed packages along with their names and versions.
Listing Installed Packages4. Querying RPM Package
To retrieve detailed information about a specific package, use the `-q` (or `--query`) option followed by the package name:
rpm -q package_name
This command will display information like the package name, version, architecture, and more.
Querying Package Information5. Verifying RPM Package
You can verify the integrity and authenticity of an RPM package without installing it using the `-V`
(or `--verify`
) option. This checks if the package's files have been modified or deleted:
rpm -V package_name
This command checks whether the package's files on disk match the information in the RPM database.
Verifying Package Integrity6. Uninstalling RPM Packages
To remove an installed package, use the `-e` (or `--erase`) option followed by the package name:
rpm -e package_name
This command will uninstall the specified package from your system.
Uninstalling PackagesReal-World Examples of RPM Command in Linux
Let's explore some practical examples of using the rpm command:
1. Installing a Package using RPM Command in Linux
Suppose you want to install a package named example.rpm:
rpm -i example.rpm
This command will install the `example. , rpm` package on your system.
2. Upgrading a Package using RPM Command in Linux
If you have a newer version of the example.rpm package and want to upgrade it, you can use the following command:
rpm -U example.rpm
This will replace the older version with the newer one.
3. Checking if a Package is Installed using RPM Command in Linux
To retrieve information about the installed example package:
rpm -q example
This will display details like the package name, version, and architecture.
4. Verifying Package Integrity using RPM Command in Linux
Check the integrity of the example package:
rpm -V example
This command will report any file discrepancies in the package.
5. Uninstalling a Package using RPM Command in Linux
To remove the example package from your system:
rpm -e example
This will uninstall the package and its associated files.
Conclusion
In this article, we discussed the RPM command which is a versatile tool for managing software packages on Linux systems, especially in RPM-based distributions. Whether you need to install, query, verify, or upgrade packages, RPM provides many options to meet your package management needs. By understanding and mastering the RPM command, you can efficiently maintain and optimize your Linux system.
Similar Reads
ls Command in Linux
The ls command is one of the most used commands in the Linux terminal to display the files and directories or path in the terminal. So, using the ls command is a basic skill for navigating the Linux file system, handling files, and managing directories.What is the ls Command in LinuxThe ls command i
10 min read
Unzip Command in Linux
As an open-source operating system, Linux presents plenty of powerful and versatile instructions for dealing with files and directories. One such command that performs an important role in coping with compressed files is the "unzip" command.Compressed files are a common way to keep space and share d
8 min read
dnf Command in Linux
Linux is a versatile operating system. It has many commands that can change the Linux working functionality of the operating system. Every Linux has a different package manager that helps us to install the software in the Linux operating system. The `dnf` command is a package manager command in Red-
4 min read
Pacman command in Arch Linux
Pacman is a package manager for the arch Linux and arch-based Linux distributions. If you have used Debian-based OS like ubuntu, then the Pacman is similar to the apt command of Debian-based operating systems. Pacman contains the compressed files as a package format and maintains a text-based packag
4 min read
Linux Commands
Linux commands are essential for controlling and managing the system through the terminal. This terminal is similar to the command prompt in Windows. Itâs important to note that Linux/Unix commands are case-sensitive. These commands are used for tasks like file handling, process management, user adm
15+ min read
Linux command in DevOps
DevOps engineers use Linux every day because itâs free, fast, and easy to customize. More importantly, most DevOps tools like Docker, Kubernetes, Ansible, Terraform, and Jenkins are built to run best on Linux.In DevOps, you often work on cloud servers (like AWS, Azure, or Google Cloud), and most of
9 min read
Update Command for Linux
The update command in Linux is used to synchronize package index files from their sources defined in /etc/apt/sources.list or /etc/apt/sources.list.d/ with the latest versions available. This makes sure that your system has the most up-to-date information about available packages and their versions,
4 min read
npm install command
The npm install command is one of the most commonly used commands in Node.js development. It allows developers to install dependencies from the package.json file as well as additional packages from the npm registry. This command simplifies the process of setting up a project managing dependencies an
5 min read
CLI Commands in NPM
NPM, short for Node Package Manager, is the default package manager for NodeJS. It is a command-line utility that allows you to install, manage, and share packages or modules of JavaScript code. These packages can range from small utility libraries to large frameworks, and they can be easily integra
4 min read
rmdir Command in Linux With Examples
In Linux, managing directories efficiently is a crucial skill for both system administrators and everyday users. The 'rmdir' command is a specialized tool designed specifically for removing empty directories, helping to maintain a clean file system and avoid accidental data loss. This guide delves i
6 min read