Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As a concrete example I want to be able to take a particular tool that isn't installed (say nslookup) and be able to tell which package I need to install when the following fails:

apt-get install nslookup
E: Unable to locate package nslookup

Obviously I can google to find the answer for a specific package (dnsutils) but I want to know how to find it myself.

share|improve this question
this is quick and dirty apt-cache search nslookup – The Unix Janitor Nov 18 '10 at 23:34
apt-cache only searches the descriptions. I was looking for specific file, ErikA pointed out: apt-file search FOO – ErebusBat Nov 22 '10 at 15:01
up vote 13 down vote accepted

There are two ways I know of to do this:

host ~ # apt-file update
host ~ # apt-file search nslookup
dnsutils: /usr/bin/nslookup
dnsutils: /usr/share/man/man1/nslookup.1.gz
gajim: /usr/share/gajim/src/common/
kaptain: /usr/share/kaptain/nslookup.kaptn
kvirc2-data: /usr/share/kvirc2/help/en/nslookup.kvihelp
libgnet2.0-0: /usr/share/doc/libgnet2.0-0/examples/dnslookup.c.gz
manpages-ja: /usr/share/man/ja/man8/nslookup.8.gz
procmail-lib: /usr/share/procmail-lib/pm-janslookup.rc
rbot: /usr/share/rbot/plugins/nslookup.rb
scrollz: /usr/share/scrollz/help/nslookup
zsh: /usr/share/zsh/4.3.4/functions/Completion/Unix/_nslookup
zsh: /usr/share/zsh/4.3.4/functions/Misc/nslookup
zsh-beta: /usr/share/zsh-beta/functions/Completion/Unix/_nslookup
zsh-beta: /usr/share/zsh-beta/functions/Misc/nslookup


host ~ # apt-cache search nslookup
host - utility for querying DNS servers
dnsutils - Clients provided with BIND
share|improve this answer
apt-cache only searches the packages you already have installed, while apt-file searches ALL packages in your sources.list, including packages that aren't installed. So in this case, apt-file is the one to use. – Steven Monday Nov 18 '10 at 23:15
@Steven, I'm going to have to disagree with that. I just did a test search for "vlc" on my ubuntu VPS using apt-cache, and it showed all of the vlc-related packages, none of which I have installed. – EEAA Nov 18 '10 at 23:21
@Steven Monai, that isn't true. apt-cache looks at package descriptions (searches /var/lib/apt/lists/*_Packages). Having something installed doesn't matter. The package descriptions don't include a list of the files. I agree that apt-file is probably the tool to use, if opening a web browser isn't an option. – Zoredache Nov 18 '10 at 23:22
There's also auto-apt, as an alternative to apt-file. I don't have a strong preference. auto-apt can listen on failed exec calls, which can be useful when running a configure script that does feature detection. – Tobu Nov 18 '10 at 23:31
@EricA, Zoredache: I stand corrected. Let me restate: If you need to know which uninstalled package contains a particular file (e.g. /usr/bin/nslookup), then use apt-file. If you only want to search the package names and descriptions, then apt-cache works just fine. – Steven Monday Nov 18 '10 at 23:57

Do you have command-not-found installed?

Just type the command in bash or zsh and it will tell you which package has it, and if you need to enable non-main repos or fix your PATH. Or call command-not-found $command_name.

Or you could go to , but that defaults to karmic packages.

share|improve this answer

Do you need to do this from the command line? I usually just do a search on (or when I am looking for packages.

share|improve this answer

Ubuntu's online repository browser has "Search the contents of packages" feature. AFAIK, it's not implemented in apt-get/aptitude, but in the most cases you will be satisfied with "apt-get search" when searching for a package containing a similarly named program.

share|improve this answer

Your Answer


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.