Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Simple enough question: is there some shell command (or GUI method) I can use that, given the path to a file on my system, tells me what package put it there? Assuming the file did in fact come from a package, that is.

Bonus question: what if it's a file that isn't installed on my system? Is there, say, a website that will let me look up a file and see what packages, if any, provide it?

share|improve this question
2  
I've always wondered this myself - I know with YUM you can do yum whatprovides <filepath>/<filename> but I never really have found an alternative to that in Aptitude other than the Packages website –  Marco Ceppi Jul 30 '10 at 13:44

5 Answers 5

up vote 48 down vote accepted

You can use dpkg command to find out which package owns a file:

From man dpkg:

-S, --search filename-search-pattern...
                  Search for a filename from installed packages.

Example:

$ dpkg -S /bin/ls
coreutils: /bin/ls

You can either search with a full path or with just the filename.

If you wish to search for files not yet installed on your computer, you can use the Ubuntu Packages Search

share|improve this answer
    
I highly recommend using dlocate, which is updated daily for faster lookups. –  Daniel T Chen Nov 23 '10 at 21:29
2  
Hint: if you do not know the full path, but just the command name, use which to find he program: dpkg -S `which firefox` –  Lekensteyn Jun 7 '11 at 15:38
    
This works for libraries as well, which is particularly handy if you have a binary that won't run because you can inspect it with ldd and use the full library paths to find the packages you are missing. –  Alain O'Dea Oct 23 at 14:41

The apt-file command can do this for you from the command line. I use it frequently when building packages from source. For files provided by packages that are already installed on your system, apt-cache is another choice.

However a much friendlier way is to use the Ubuntu Packages Search website. They have an option to "search the contents of packages" for a specific filename.

share|improve this answer

One reason you might have to do this is if you are compiling software which there already is an ubuntu package, you can run apt-get build-dep $PACKAGENAME. That will install all packages you need to compile $PACKAGENAME.

share|improve this answer

You can search the contents of packages included in the various Ubuntu releases on the Ubuntu Packages website. Look under the heading "Search the contents of packages".

For example, here are the search results for libnss3.so in lucid (10.04):

http://packages.ubuntu.com/search?searchon=contents&keywords=libnss3.so&mode=exactfilename&suite=lucid&arch=any

share|improve this answer

There's also apt-file for looking up files in packages that aren't installed.

share|improve this answer
    
exactly what i was searching for. thanks –  NES Feb 5 '11 at 12:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.