- 15+ rpm command examples in Linux [Cheat Sheet]
- Different examples to use rpm command
- 1. rpm command to install an RPM package
- 2. Check an installed RPM package with rpm command
- 3. rpm command to upgrade an RPM package
- 4. Remove an RPM package with rpm command
- 5. Check dependencies of an RPM package using rpm command
- 6. rpm command to print the information of an RPM package
- 7. rpm command to get information of an installed package
- 8. Install an RPM package without dependencies with rpm command
- 9. rpm command to list all files of an installed RPM package
- 10. Remove an RPM package without dependencies using rpm command
- 11. List all installed RPM packages with rpm command
- 12. List only recently installed RPM packages with rpm command
- 13. Verify an RPM package with rpm command
- 14. rpm command to verify all RPM packages
- 15. Query a file with rpm command
- 16. rpm command to check signatures in an RPM package
- 17. Import an RPM GPG key with rpm command
- Conclusion
- 3 Ways to List All Installed Packages in RHEL, CentOS and Fedora
- 1. Using RPM Package Manager
- 2. Using YUM Package Manager
- 3. Using YUM-Utils
- Related Posts
- 3 thoughts on “3 Ways to List All Installed Packages in RHEL, CentOS and Fedora”
15+ rpm command examples in Linux [Cheat Sheet]
RPM (Red Hat Package Manager) is an open-source package management tool in RHEL based systems such as RHEL, CentOS, and Fedora. You can install, update, remove, or verify RPM packages with this tool. RPM only works with .rpm files, so you need to have a .rpm file in your system. The .rpm file stores the installation packages of RPM-based Linux distribution.
Different examples to use rpm command
Since you will need to have .rpm files, you can download them from here. You can also use the dnf command to download the rpm package using this command.
$ sudo dnf install package_name --downloadonly --downloaddir=DIR_PATH
You can find our detailed article on dnf at 25+ DNF command practical examples in Linux.
In this article, we will learn how to use rpm commands to manage the RPM packages on the system.
1. rpm command to install an RPM package
You can use -i or —install option to install an RPM package on your system. The RPM package must be available in your workstation.
$ sudo rpm --install rpm_filename
Sample Output:
In the following example, we are installing single rpm. If this rpm has any dependency over other rpm then that must be manually handled by downloading that rpm and installing them both together or else the installation will fail with dependency error.
- -v: To display the verbose output
- -h: To print the hash symbol progress bar
2. Check an installed RPM package with rpm command
You can use -q option to check whether an RPM package is installed in your system or not.
Sample Output:
As you can see, iotop is installed in our system. The package name that you provide may be incorrect, so you can also try the following command
$ sudo rpm -qa | grep package_name
This command can also help you check if the provided package is installed or not.
3. rpm command to upgrade an RPM package
-U or —upgrade option allows you to upgrade any RPM package to the latest version. This is the same as install, except all other version(s) of the package are removed after the new package is installed.
$ sudo rpm --upgrade rpm_filename
Sample Output:
4. Remove an RPM package with rpm command
You can remove an installed package from your system with -e or —erase option.
$ sudo rpm --erase package_name
Sample Output:
In some cases, this command fails to remove the package from the system due to unresolved dependencies. So, the best way to remove RPM packages and their dependencies is by using yum or dnf command.
5. Check dependencies of an RPM package using rpm command
This command allows you to check the dependencies of an RPM package on the system.
$ sudo rpm -qpR rpm_filename
Sample Output:
- -q: To query an RPM package
- -p: To query an uninstalled package
- -R: To list capabilities on which the package depends
6. rpm command to print the information of an RPM package
With the help of this command, you can get the information of an RPM package on your system.
$ sudo rpm -qip rpm_filename
Sample Output:
7. rpm command to get information of an installed package
Sometimes, you may want to get the information of any installed packages on the system. In that case, you can use this command.
Sample Output:
8. Install an RPM package without dependencies with rpm command
—nodeps option allows you to install an RPM package without dependencies. It ignores the dependencies errors and forcefully installs an RPM package. Some programs may not work until you install the required dependencies.
$ sudo rpm -ivh --nodeps rpm_filename
Sample Output:
This is strictly not recommended as this can potentially break your system for more complex rpms such as kernel, gcc etc.
9. rpm command to list all files of an installed RPM package
You can use this command to list all the files of an installed RPM package.
Sample Output:
10. Remove an RPM package without dependencies using rpm command
You can also use —nodeps option with the erase command to uninstall an RPM package without checking dependencies. It ignores all the dependencies errors and forcefully removes the package.
$ sudo rpm -ev --nodeps package_name
Sample Output:
Now, let’s check if the package is removed.
The package is removed, but the dependencies are still present in the system.
This is strictly not recommended as this can potentially break your system for more complex rpms such as kernel, gcc.
11. List all installed RPM packages with rpm command
To view the list of all installed RPM packages in your system, you can use this command.
Sample Output:
12. List only recently installed RPM packages with rpm command
You can use this command to view the list of recently installed RPM packages on your system.
Sample Output:
13. Verify an RPM package with rpm command
-V or —verify option allows you to verify an RPM package against the rpm database. It compares the installed package information with package metadata stored in the rpm database. It also compares the size, digest, permissions, type, owner, and group of each file.
$ sudo rpm --verify -p rpm_filename
Sample Output:
14. rpm command to verify all RPM packages
You can use this command to verify all RPM packages.
Sample Output:
15. Query a file with rpm command
You can also query a file and find to which RPM package it belongs.
$ sudo rpm -qf [file_name or file_path]
Sample Output:
16. rpm command to check signatures in an RPM package
—checksig option checks all the digests and signatures contained in an RPM package file. It is a useful command to verify the integrity and origin of the package is ok.
$ sudo rpm --checksig rpm_filename
Sample Output:
17. Import an RPM GPG key with rpm command
You can import a GPG key with —import option. RPM GPG key files are located in the /etc/pki/rpm-gpg directory.
$ sudo rpm --import RPM-GPG-KEY_File
Sample Output:
You can list all imported GPG keys with the following command.
Sample Output:
Conclusion
This article shows you the practical examples of rpm command on RPM-based Linux distribution. rpm is a powerful package manager tool to install, remove, update, query, and verify RPM packages. We hope that you can now manage the RPM packages using rpm command. If you have any questions, you can use the comment section below.
3 Ways to List All Installed Packages in RHEL, CentOS and Fedora
One of the several duties of a system administrator is to install and manage software on a computer system-Linux in this case and in order keep track of installed/available software packages on your system, you can learn, and/or keep in mind a few quick commands.
In this article, we will explain how to list all installed rpm packages on CentOS, RHEL and Fedora distributions using four different ways.
1. Using RPM Package Manager
RPM (RPM Package Manager) formerly known as Red-Hat Package Manager is an open source, low-level package manager, which runs on Red Hat Enterprise Linux (RHEL) as well as other Linux such as CentOS, Fedora and UNIX systems.
You can compare it to DPKG Package Manager, the default packaging system for Debian and it’s derivatives such as Ubuntu, Kali Linux etc.
The following command will print a list of all installed packages on your Linux system, the flag -q meaning query and -a enables listing of all installed packages:
2. Using YUM Package Manager
YUM (Yellowdog Updater, Modified) is an interactive, front-end rpm based, package manager.
You can use the yum command below to list all installed packages on your system, one advantage with this method is, it includes the repository from which a package was installed:
3. Using YUM-Utils
Yum-utils is an assortment of tools and programs for managing yum repositories, installing debug packages, source packages, extended information from repositories and administration.
To install it, run the command below as root, otherwise, use sudo command:
# yum update && yum install yum-utils
Once you have it installed, type the repoquery command below to list all installed packages on your system:
To list installed packages from a particular repository, use the yumdb program in the form below:
# yumdb search from_repo base
Read more about package management in Linux:
In this article, we showed you how to list all installed packages on CentOS or RHEL four different ways. Share your thoughts concerning this article via the feedback section below.
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.
Related Posts
3 thoughts on “3 Ways to List All Installed Packages in RHEL, CentOS and Fedora”
Hi. Since the release of Fedora 22, in which DNF became the new default packaging tool and therefore obsoleted yum command on subsequent Fedora OSs, YUM was kept on those Fedora OSs for compatibility reason regarding Linux distributions forked from the Fedora project (Red Hat, Centos) that kept on using YUM, and will be kept for that very reason until they adopt it definitively. I had little time before your previous post as reply, to test a command of my investigation that also relies as well on expression ‘wc -l‘ . Such command is likely to cover all current active repositories on a system which is indeed exactly what I was aiming to. Here are for comparative purpose the following commands (by the way, there is no need to be executed as user root): ‘dnf list installed|wc -l‘, ‘rpm -qa|wc -l‘ respective outputs: 1619, 1590. As noticeable those outputs are incorrect which is no surprise after investigation. Their subsequent commands are inappropriate; they do not reflect exclusively the current active repositories on my system, which in that case are fedora, updates which respectively contain 54 801, 13 085 packages (subsequent results are available from another command too). Good luck though in your hobby. Reply
Hi. For Fedora, as output, the number (not the list) of all packages (available and installed) regarding a specific added repository . Regards. Reply
@Ricky You can pipe the output of the above commands to wc utility with the -l switch, to get the number instead of a list of installed packages, like this:
# yum list installed | wc -l OR # rpm -qa | wc -l