Wednesday, July 14, 2010

How do I find which package contains a certain file?

What to do if you need to install or build a package on Linux and it wants a missing file/library/etc...

Have you ever tried to install package or some vendor software, only to find that the install fails due to a missing library? Here is a collection of methods for finding the package that contains the missing file.

Red Hat Enterprise Linux/CentOS

Using yum

yum whatprovides /full/path/to/missing/filename
Note: In all of these processes, fill in the actual filename and path for which you are looking.

Using rpmfind site

  1. Browse to http://rpm.pbone.net/index.php3/stat/2/simple/2
  2. Enter filename or /full/path/to/missing/filename in the search box (start with just the filename)
  3. Check boxes of rpm-based distributions in which you want to search
  4. Click search

Debian/Ubuntu

apt-file

sudo aptitude install apt-file
sudo apt-file update
apt-file search filename
or
apt-file search /full/path/to/missing/filename

Using Debian's website

  1. Browse to http://www.debian.org/distrib/packages
  2. Scroll to the bottom to the section called "Search the contents of packages"
  3. Enter a single argument into the search field, either filename or /full/path/to/missing/filename
  4. Select your distribution
  5. Select the machine architecture for which you need the missing file
  6. Click "Search"