Tuesday, February 28, 2012

How to locate a package that provides a specific file

It happens usually that I need a specific file and I have to find out which package provides it. Some package managers, such as yum (Fedora, Red Hat and its derivatives) and urpm (Mandriva, Mageia, blackPanther OS), have built-in action for that purpose. Aptitude and apt-get do not have. :( There are, however, some tools in Debian that search in the content of any packages. dpkg -S, e.g., does that job, however it works only for packages already installed on your system. Other tools, such as apt-file and wajig does not have this limitation. Because of some reason, I prefer apt-file. So, let's see how it works.


First, you need to install it, since it is not installed by default:

# aptitude install apt-file

Then, you need to update its database:

# apt-file update

Finally, you can use it to find out which package provides the file you need:

$ apt-file search file-name

You can use perl regexp easily by applying the -x option. Without that, the file-name is treated as literal string. For more information see man apt-file or visit 1 or 2.


No comments:

Post a Comment