5

Given the name of a binary (or any other program). How to find out which package provides this binary?

Note: Assuming one uses apt/dpkg for package managing.

Edit

Additional to the correct answer below, I'd like to add some further information: In the question above I was assuming that the corresponding package was installed. If this is not the case, there is a package called apt-file which could do the job anyway.

Searching for the mysqldump tool could be done with

$ apt-file --regexp search .*mysqldump$

Resulting in:

mariadb-client-10.0: /usr/bin/mysqldump
mysql-client-5.5: /usr/bin/mysqldump

This solution was found here but I thought it could be of use to mention it here.

6

You want dpkg. Specifically the -S option will find which package owns a file.

An example:

$ dpkg -S /usr/bin/whereis
util-linux: /usr/bin/whereis

The example shows that util-linux is the package which contains /usr/bin/whereis.

2
dpkg --search /usr/bin/mysqldump
dpkg -S /usr/bin/mysqldump

The argument of dpkg --search is a shell wildcard pattern, so you can do things like dpkg -S bin/*dump.

Alternatively, you can search the database manually — it's just text files.

grep mysqldump /var/lib/dpkg/info/*.list

On a system with a lot of packages installed, dpkg -S can be slow because it has to read a lot of small files in /var/lib/dpkg/info. You can install dlocate which indexes files installed via deb packages in the same way that locate indexes all files: the information is a bit stale (by default, the database is updated nightly) but the query operation is faster.

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.