I know how to use rpm to list the contents of a package (rpm -qpil package.rpm
). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use the package manager, which in my case is YUM. How can YUM be used to achieve this?

- 57,372
- 31
- 105
- 141
-
10Without the `-p` param (`rpm -ql packageName`) you don't need to know the location of the rpm file. It's pretty much the easiest way to get "all the" path's of a package. For some example output see [my answer](http://stackoverflow.com/a/26711409/1680919). – Levite Feb 09 '15 at 07:24
-
2Unfortunately that only works with installed packages – WallStProg May 10 '17 at 16:38
7 Answers
There is a package called yum-utils
that builds on YUM and contains a tool called repoquery
that can do this.
$ repoquery --help | grep -E "list\ files"
-l, --list list files in this package/group
Combined into one example:
$ repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz
On at least one RH system, with rpm v4.8.0, yum v3.2.29, and repoquery v0.0.11, repoquery -l rpm
prints nothing.
If you are having this issue, try adding the --installed
flag: repoquery --installed -l rpm
.
DNF
Update:
To use dnf
instead of yum-utils
, use the following command:
$ dnf repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz

- 45,622
- 19
- 93
- 125

- 36,043
- 14
- 56
- 60
-
13Note that this command will fail silently if the named package doesn't actually exist. – Joshua Hoblitt Sep 30 '12 at 18:22
-
19To search faster for installed packages, include --installed option. eg `$ repoquery -lq --installed time`. – Mohsenme Mar 05 '14 at 08:06
-
-
9
-
I just quickly scanned the man page, it's not possible to see what is a file and what is a symllink, or is it? – Andy May 11 '18 at 21:09
-
2
rpm -ql [packageName]
Example
# rpm -ql php-fpm
/etc/php-fpm.conf
/etc/php-fpm.d
/etc/php-fpm.d/www.conf
/etc/sysconfig/php-fpm
...
/run/php-fpm
/usr/lib/systemd/system/php-fpm.service
/usr/sbin/php-fpm
/usr/share/doc/php-fpm-5.6.0
/usr/share/man/man8/php-fpm.8.gz
...
/var/lib/php/sessions
/var/log/php-fpm
No need to install yum-utils, or to know the location of the rpm file.

- 17,263
- 8
- 50
- 50
-
4This seems to be the equivalent of `dpkg -L` for all ya'll who don't want to install another package just to list files. – Dmitry Minkovsky Nov 04 '14 at 01:08
-
6@dimadima: The question was for **yum** (= RHEL based systems) which uses `rpm` as native packet manager (**R**ed Hat **P**acket **M**anager). If the OP would be on a debian/ubuntu/.. system, `dpkg` would be the way to go, since it is the backend to **apt**. – Levite Nov 04 '14 at 07:15
-
3@Levit: Pretty sure what dimadima is trying to say is that this doesn't strictly answer the question -- you're not using `yum` but `rpm` which has the major implication that the package needs to be installed (which OP didn't explicitly say was his scenario). He was merely making the rpm==dpkg / yum==apt parallel comparison to explain this in case somebody was familiar with Debian-based packaging and not RH-based packaging. – tne Jan 31 '15 at 14:16
-
@Levit: Yes, just like everything apt does uses dpkg in the background -- at least that's the analogy I think he was using. Anyway, regardless of what he was trying to say, my bit of added information was merely the fact that rpm alone will not query the repos for uninstalled packages information, hence the need for yum in that scenario ("if you don't want to install another package just to list files"; dimadima's words). – tne Feb 09 '15 at 08:43
-
3^1 because for some reason, this works and the accepted answer returns nothing – Izkata May 02 '16 at 19:30
-
This won't work on packages that are not installed. Yum can fetch file list dbs for its repos, which is how `yum whatprovides {{filename}}` works. – Apr 19 '17 at 03:10
-
2It seems there is no `yum` equivalent to `rpm -ql` and `repoquery -l` (from `yum-utils` package) commands to list local and remote files, respectively. – Jun 12 '17 at 14:37
-
1This only applies to locally installed rpms. Querying the content of remote, available but not installed packages does not work. One gets the message `package
is not installed`. – Hans Deragon Mar 29 '19 at 15:34
I don't think you can list the contents of a package using yum, but if you have the .rpm file on your local system (as will most likely be the case for all installed packages), you can use the rpm command to list the contents of that package like so:
rpm -qlp /path/to/fileToList.rpm
If you don't have the package file (.rpm), but you have the package installed, try this:
rpm -ql packageName

- 8,084
- 8
- 48
- 62

- 11,647
- 13
- 72
- 110
-
25if you don't have the package file (.rpm), but you have the package installed, try rpm -ql packageName – Jared Updike May 10 '11 at 01:24
-
1if you don't have the package and it is not installed, you can find the url of the package with `youdownload --urls`. – kamae Jun 30 '11 at 08:43
-
There are several good answers here, so let me provide a terrible one:
: you can type in anything below, doesnt have to match anything
yum whatprovides "me with a life"
: result of the above (some liberties taken with spacing):
Loaded plugins: fastestmirror
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/4): extras/7/x86_64/primary_db | 166 kB 00:00
(2/4): base/7/x86_64/group_gz | 155 kB 00:00
(3/4): updates/7/x86_64/primary_db | 9.1 MB 00:04
(4/4): base/7/x86_64/primary_db | 5.3 MB 00:05
Determining fastest mirrors
* base: mirrors.xmission.com
* extras: mirrors.xmission.com
* updates: mirrors.xmission.com
base/7/x86_64/filelists_db | 6.2 MB 00:02
extras/7/x86_64/filelists_db | 468 kB 00:00
updates/7/x86_64/filelists_db | 5.3 MB 00:01
No matches found
: the key result above is that "primary_db" files were downloaded
: filelists are downloaded EVEN IF you have keepcache=0 in your yum.conf
: note you can limit this to "primary_db.sqlite" if you really want
find /var/cache/yum -name '*.sqlite'
: if you download/install a new repo, run the exact same command again
: to get the databases for the new repo
: if you know sqlite you can stop reading here
: if not heres a sample command to dump the contents
echo 'SELECT packages.name, GROUP_CONCAT(files.name, ", ") AS files FROM files JOIN packages ON (files.pkgKey = packages.pkgKey) GROUP BY packages.name LIMIT 10;' | sqlite3 -line /var/cache/yum/x86_64/7/base/gen/primary_db.sqlite
: remove "LIMIT 10" above for the whole list
: format chosen for proof-of-concept purposes, probably can be improved a lot
currently reopquery
is integrated into dnf
and yum
, so typing:
dnf repoquery -l <pkg-name>
will list package contents from a remote repository (even for the packages that are not installed yet)
meaning installing a separate dnf-utils
or yum-utils
package is no longer required for the functionality as it is now being supported natively.
for listing installed or local (*.rpm
files) packages' contents there is rpm -ql
i don't think it is possible with yum
org dnf
(not repoquery
subcommand)
please correct me if i am wrong
Yum doesn't have it's own package type. Yum operates and helps manage RPMs. So, you can use yum to list the available RPMs and then run the rpm -qlp command to see the contents of that package.

- 1,413
- 2
- 13
- 17