This article is part of the following series.
- 4 ways to list files within a rpm package in Linux
- 3 ways to Check RPM package dependency in Linux
- How to use yum to list All versions of Package in Linux
- 5 ways to list installed packages in Linux
If you’re working with an RPM-based Linux distribution, you may need to list the files that are contained within an RPM package. This can be useful for a variety of reasons, such as troubleshooting or understanding what changes an installation made to your system.
In this post, we’ll explore a few different methods for listing files in an RPM package. Let’s get started.
Table of Contents
display a list of files within a local rpm package
If there is an RPM file available on local system, you can use the following rpm command to list the files:
rpm -qlp /path/to/package.rpm
The command “rpm -qlp /path/to/package.rpm” is used to query information about an RPM package file. Here’s what each part of the command means:
- “rpm” is the command-line tool used for managing RPM packages on Linux systems.
- “-qlp” are options for the “rpm” command.
- “q” stands for query mode
- “l” stands for list the contents of the package.
- “p” specifies that the package being queried is not installed, but is a file located on the system.
- “/path/to/package.rpm” is the path to the RPM package file you want to query.
So, when you run this command, it will display a list of all the files included in the RPM package file. This can be useful for checking what files are included in the package before installing it.
Suppose you have downloaded an RPM package named “example-package-1.0-1.rpm” and saved it to the “/tmp” directory. You can run the command:
rpm -qlp /tmp/example-package-1.0-1.rpm
This will display a list of all the files that are included in the “example-package” RPM package, without installing it.
list a list of files within a installed rpm package
If there is a package already installed, contents listing can be done with this rpm command:
rpm -ql package-name
The command “rpm -ql package-name” is used to list the files that are installed on the system by the specified RPM package. “package-name” is the name of the RPM package you want to query.
Let’s see that you want to list the files that are installed on your system by the RPM package named “httpd”, you can run the command:
rpm -ql httpd
This will display a list of all the files that are installed on the system by the “httpd” RPM package. The list may include files such as configuration files, executable binaries, documentation files, and so on. By examining the list, you can gain a better understanding of what the package contains.
list a list of files in a rpm package with dnf command
dnf repoquery -l package-name
The command “dnf repoquery -l package-name” can be used to list the files that are included in the specified RPM package that is available in the enabled repositories on your system. Here’s what each part of the command means:
- “dnf” is a package manager for RPM-based Linux distributions like Fedora, CentOS, and RHEL.
- “repoquery” is a plugin for dnf that provides a way to query information about RPM packages in the enabled repositories on your system.
- “-l” is an option or flag for the “repoquery” command that specifies to list the files that are included in the package.
- “package-name” is the name of the RPM package you want to query.
The dnf repoquery command allows you to query information about packages in a repository using the DNF package manager. You can use this command to query package dependencies,find which package provides a file etc.
display a list of files in a rpm package with repoquery command
Repoquery is a command-line tool that allows you to query information about packages in a repository. It is a part of the yum-utils package on Linux systems that use the yum package manager.
repoquery -l package-name
This command requires the “yum-utils” package to be installed on your system. If you don’t have it installed, you can install it using the command “sudo yum install yum-utils”.
To list the files contained in the “httpd” package, you can use the following command:
repoquery --list httpd
Here are more common use cases for repoquery:
- Query package dependencies: You can use repoquery to list the dependencies of a package, including its dependencies on other packages in the same repository.
- Find which package provides a file: If you need to find which package provides a particular file, you can use repoquery to search the repository for packages that contain that file.
- Show package information: Repoquery can display various information about a package, including its name, version, architecture, and size.
To use repoquery, you typically need to specify the name of the package you want to query or the file you want to search for. You can also use various options and arguments to filter and customize the output of the command.
For example, to list the dependencies of the “httpd” package, you can use the following command:
repoquery --requires httpd
To find which package provides the “ls” command, you can use the following command:
repoquery --whatprovides /bin/ls
These are just a few examples of the many ways you can use repoquery to query information about packages in a repository.