3

Possible Duplicate:
How do I find the package that provides a file?

When you type a command in the terminal in Ubuntu that you have not installed but can supplied by a package Ubuntu will suggest the package to be installed.

How do I do the other way around? How do I look for what package supplied the command I am typing in a terminal?

dpkg -S /usr/bin/termit

returns

termit: /usr/bin/termit


apt-file find /usr/bin/termit

returns

termit: /usr/bin/termit

Where termit is an terminal emulator supplied by package termit.

enter image description here

Bruno Pereira
  • 73,643
  • 1
    Supplied solutions do not work in 11.10. – Bruno Pereira Oct 27 '11 at 22:27
  • 2
    Uh? I don't have 11.10 to check, but I'd be very surprised if dpkg -S didn't work, it's a basic command that doesn't change over time, and you even seem to be saying in your edited question that it does work. apt-file find should work too, though you might need to run sudo apt-file update once and for all first (previous versions of Ubuntu did it automatically when you installed the apt-file package). In what way are dpkg -S and apt-file find (which were given as answers here as well as in the earlier similar question) unsuitable? – Gilles 'SO- stop being evil' Oct 27 '11 at 22:36
  • Then either I am doing it wrong or there is something wrong, anyways a solution would be nice. Included a screen shot, let me know if something is wrong. Thanks for the comment anyways. apt-file find was run after update. – Bruno Pereira Oct 27 '11 at 22:45
  • 2
    Could you rephrase your question then? As far as I can tell, the screenshot shows you getting the answer you wanted, which is that the file /usr/bin/termit is provided by the package termit. – Gilles 'SO- stop being evil' Oct 27 '11 at 22:47
  • 1
    Holy sh*t big fail, really. It works as it should. Just sleepy I think. Thanks for forcing it down :) – Bruno Pereira Oct 27 '11 at 22:51
  • Gave reputation to answers, will close this in 3 mins. – Bruno Pereira Oct 27 '11 at 22:52

2 Answers2

5

If you have apt-file installed and configured, you can do:

apt-file find <filename>

This is also handy when you're looking for a command that you don't have installed yet, e.g. if you're working from instructions seen on the web that use a command you don't have.

If you only want to query packages that are installed, you can use:

dpkg -S <pattern>

E.g. for a file that is installed:

% apt-file find /usr/bin/oodraw
openoffice.org-draw: /usr/bin/oodraw
% dpkg -S oodraw
openoffice.org-draw: /usr/share/man/man1/oodraw.1.gz
openoffice.org-draw: /usr/bin/oodraw

and for a file that is not installed:

% dpkg -S /usr/bin/python3.1
dpkg: /usr/bin/python3.1 not found.
% apt-file find /usr/bin/python3.1
python3.1-dbg: /usr/bin/python3.1-dbg
python3.1-dbg: /usr/bin/python3.1-dbg-config
python3.1-dbg: /usr/lib/debug/usr/bin/python3.1
python3.1-dbg: /usr/lib/debug/usr/bin/python3.1-dbg-gdb.py
python3.1-dbg: /usr/lib/debug/usr/bin/python3.1-gdb.py
python3.1-dev: /usr/bin/python3.1-config
python3.1-minimal: /usr/bin/python3.1
bstpierre
  • 2,086
  • This is not giving me what I am looking for. ie: apt-file find termit returns everything expect the name of the package that installed termit. `apt-file find /usr/bin/termit' only returns the path to the file. – Bruno Pereira Oct 27 '11 at 21:04
  • Nice. I didn't know about apt-file. – zpletan Oct 27 '11 at 22:55
  • Note that for apt-file to be useful, you have to run apt-file update first -- it takes a while to build the database the first time, but after that finding what you want is quick. (Usually quicker than dpkg -S.) – bstpierre Oct 27 '11 at 22:57
2

If you are using /usr/bin/ls (you can find absolute paths of executables via the which command), you can find what package provided by running:

dpkg -S /usr/bin/ls

Alternatively, running

dpkg -S ls

will search for files named ls (or some heuristic like that) in all installed packages and return a list of them for you, formatted as PACKAGE: /path/to/file.

zpletan
  • 3,373