Listing Files Associated with RPMs



Listing Files Associated with RPMs

Sometimes you'll find yourself installing software that terminates with an error requesting the presence of a particular file. In many cases the installation program doesn't state the RPM package in which the file can be found. It is therefore important to be able to determine the origin of certain files by listing the contents for RPMs in which you suspect the files might reside.

Listing Files for Already Installed RPMs

This can be useful if you have to duplicate a working server that is already in a production environment. Sometimes the installation of an application fails on the new server due to the lack of a file that resides on the old one. In this case you need to know which RPM on the old server contains the file.

You can use the -ql qualifier to list all the files associated with an installed RPM. In this example we test to make sure that the NTP package is installed using the-q qualifier, and then we use the -ql qualifier to get the file listing:

     [root@bigboy tmp]# rpm -q ntp
     ntp-4.1.2-0.rc1.2
     [root@bigboy tmp]# rpm -ql ntp
     /etc/ntp
     /etc/ntp.conf
     /etc/ntp/drift
     /etc/ntp/keys
     ...
     ...
     ...
     /usr/share/doc/ntp-4.1.2/rdebug.htm
     /usr/share/doc/ntp-4.1.2/refclock.htm
     /usr/share/doc/ntp-4.1.2/release.htm
     /usr/share/doc/ntp-4.1.2/tickadj.htm
     [root@bigboy tmp]#

Listing Files in RPM Files

Sometimes you make a guess and download what you think is the RPM with the missing file. You can use the -qpl qualifier to list all the files in an RPM archive to make sure before installing it:

     [root@bigboy updates]# rpm -qpl dhcp-3.0pl1-23.i386.rpm
     /etc/rc.d/init.d/dhcpd
     /etc/rc.d/init.d/dhcrelay
     /etc/sysconfig/dhcpd
     /etc/sysconfig/dhcrelay
     ...
     ...
     ...
     /usr/share/man/man8/dhcrelay.8.gz
     /var/lib/dhcp
     /var/lib/dhcp/dhcpd.leases
     [root@bigboy updates]#

Listing the RPM to Which a File Belongs

You might need to know the RPM that was used to install a particular file. This is useful when you have a suspicion about the function of a file but are not entirely sure. For example, the MySQL RPM uses the /etc/my.cnf file as its configuration file, not a file named /etc/mysql.conf as you'd normally expect. The following example confirms the origin of the /etc/my.cnf file:

     [root@zippy tmp]# rpm -qf /etc/my.cnf
     mysql-3.23.58-9
     [root@zippy tmp]#