Which package does a file belong to? (RPM Style)

If you want to figure out which package a file belongs to you can use rpm to find out (On a system that uses rpm). Which package does /bin/bash belong to?


[root@host ~]# rpm -qf /bin/bash
bash-3.0-19.3

So /bin/bash belongs to bash-3.0-19.3

The -q option lets rpm know that you want to do a query of the database. The f lets you query the package containing the file you specify.

Here’s another query:


[root@host ~]# rpm -qf /usr/bin/xargs
findutils-4.1.20-7.el4.1
[root@host ~]#

yum lets you get info on the findutils package:


[root@host ~]# yum info findutils
Setting up repositories
update 100% |=========================| 951 B 00:00
rpmforge 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Installed Packages
Name : findutils
Arch : i386
Epoch : 1
Version: 4.1.20
Release: 7.el4.1
Size : 231 k
Repo : installed
Summary: The GNU versions of find utilities (find and xargs).


Description:
The findutils package contains programs which will help you locate
files on your system. The find utility searches through a hierarchy
of directories looking for files which match a certain set of criteria
(such as a filename pattern). The xargs utility builds and executes
command lines from standard input arguments (usually lists of file
names generated by the find command).


You should install findutils because it includes tools that are very
useful for finding things on your system.

So, if you are using a system that uses RPM/YUM, you can easily find out the packages that files on your filesystem belong to.

Once you have identified the package that you are looking for you may wish to find out which files are part of that package. To do so you use the query list option (-ql). Here is an example for the bash package:


[dustin@host ~]$ rpm -ql bash
/bin/bash
/bin/sh
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
/usr/bin/bashbug-32
/usr/share/doc/bash-3.0
/usr/share/doc/bash-3.0/CHANGES
--snip--
/usr/share/man/man1/unset.1.gz
/usr/share/man/man1/wait.1.gz
[dustin@host ~]$

This entry was posted on Friday, April 13th, 2007 at 1:50 am and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses to “Which package does a file belong to? (RPM Style)”

  1. victor says:

    For the sake of completion, once you know the utilities,
    how can you list the files contained in a yum package ?
    thx

  2. kanske says:

    Victor,

    I updated the post to show how to query a package to see the files inside that package (example bash).

Leave a Reply