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 ~]$
For the sake of completion, once you know the utilities,
how can you list the files contained in a yum package ?
thx
February 1st, 2011 at 12:37 pm
Victor,
I updated the post to show how to query a package to see the files inside that package (example bash).
February 3rd, 2011 at 1:55 am