I recently installed java6 on my debian box. I went to use javac and noticed it wasn't installed. Eventually I figured out (after searching online) that javac is part of the java6-sdk package. This isn't the first time where I've know the command I want, but I don't know the package(s) it's in.

My question is- is there a way to on the command line to figure out what file belongs to what package(s)? So if I wanted to see what packages javac belonged to, it would list java6-sdk, java5-sdk, .. since they all contain javac.


apt-file is the command you're looking for.


You can use apt-file search filename for that. You could just go to Debian Packages and search the online version.


I know this isn't exactly what your looking for, but:

dpkg -L packagename

will list all of the files belonging to an installed package. (but you want this for uninstalled packages)

I don't know how it does this, but Ubuntu (derived from Debian) will suggest a package as follows:

$ chkrootkit
The program 'chkrootkit' is currently not installed.  You can install it by typing:
sudo apt-get install chkrootkit
bash: chkrootkit: command not found

And I have often done the obvious, and typed the name of the file, along with "Debian" into google to find the package.

  • 2
    The package is called "command-not-found - Suggest installation of packages in interactive bash sessions" and it's available in Debian as well, but installed by default on Ubuntu.
    – LiraNuna
    Jul 8 '09 at 18:03

you might also want to look at the dlocate package. it has many useful options for listing packages and files within packages. it was originally written to be a much faster version of dpkg -L, dpkg -S etc but has gained many useful features over the years (while still retaining the speed :)

DISCLAIMER: I'm the author and debian maintainer of dlocate.

BTW, install the version of dlocate from testing or unstable. it has numerous improvements over the version in stable (in particular, it doesn't depend on GNU locate any more) and still works fine in stable (doesn't depend on any new/updated libs etc).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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