up vote 9 down vote favorite
1
share [g+] share [fb]

I frequently find myself missing a program, man page, or other file when working on my Ubuntu 8.04 system. Is there any simple way to look up what package contains a given file (whether it is installed already or not)? Maybe some obscure option for apt or dpkg?

link|improve this question

75% accept rate
feedback

4 Answers

up vote 13 down vote accepted
apt-file search filename

or

apt-file search /path/to/file


To install apt-file, use:

apt-get install apt-file

you will need to update its database before you can use it:

sudo apt-file update
link|improve this answer
1  
apt-file package needs to be installed, and isn't by default. – jtimberman Jul 22 '09 at 19:13
feedback

(Debian/Ubuntu) Discover what package a file belongs to:

dpkg -S /usr/bin/ls

'dpkg -S' just matches the string you supply it, so just using 'ls' as an argument matches any file from any package that has 'ls' anywhere in the filename. So usually it's a good idea to use an absolute path. You can see in the second example that 12 thousand files that are known to dpkg match the bare string 'ls'.

link|improve this answer
That is only if the files already installed – John T Jul 22 '09 at 19:16
feedback

packages.debian.org is what I always use to accomplish this task. It is superior over apt-file because it can find parts of filenames as well. It's also linked up to the main packages list which will list descriptions, bugs, etc. All in all a good website. Not as useful from the command line, but still quite useful.

For speed, I bookmarked the url:

http://packages.debian.org/search?searchon=contents&keywords=%s&mode=filename&suite=unstable&arch=any

in Firefox, and added "debfind" as a keyword (click "more" in the bookmark manager with it hilighted), so I can just type "debfind " and it will work. You can change 'suite' it from unstable to stable or testing if you like, for other versions of the distribution.

link|improve this answer
feedback

You can also use dlocate. From the man page;

$ dlocate [ PATTERN ]
List all records where either the package name or the filename matches PATTERN.
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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