25

Fedora's yum package management tool has a nice option called whatprovides, which lets you find what package has installed a specific binary or file. What is the equivalent command on Ubuntu?

For example, say I'd like to find what package provided /usr/bin/mysqladmin. I know it should be something like mysql-server*. I've read that apt-cache search blah is a similar command, but running apt-cache search /usr/bin/mysqladmin returns nothing. Is there a better command?

underscore_d
  • 6,309
  • 3
  • 38
  • 64
Cerin
  • 60,957
  • 96
  • 316
  • 522
  • 6
    In nower days it is `yum provides` in Fedora. There is a very nice summary for the differences of package management tools from Fedora/Red Hat to Ubuntu/Debian: https://help.ubuntu.com/community/SwitchingToUbuntu/FromLinux/%20RedHatEnterpriseLinuxAndFedora – erik Feb 16 '14 at 13:53

2 Answers2

29

I believe apt-file will give you what you want.

$ apt-file update
$ apt-file list mysqladmin
kmysqladmin: /usr/bin/kmysqladmin

$ apt-file search mysqladmin
autoconf-archive: /usr/share/aclocal/ac_prog_mysqladmin.m4
autoconf-archive: /usr/share/autoconf-archive/html/ac_prog_mysqladmin.html
bash-completion: /etc/bash_completion.d/mysqladmin
kmysqladmin: /usr/bin/kmysqladmin

$ apt-file search mysqladmin
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_health.xml
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_startup_variables_description.dtd
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_startup_variables_description.xml
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_status_variables.xml
mysql-admin: /usr/share/mysql-gui/administrator/mysqladmin_system_variables.xml
mysql-client-5.1: /usr/bin/mysqladmin
mysql-client-5.1: /usr/share/man/man1/mysqladmin.1.gz
mysql-cluster-client-5.1: /usr/bin/mysqladmin
mysql-cluster-client-5.1: /usr/share/man/man1/mysqladmin.1.gz
mysql-testsuite: /usr/lib/mysql-testsuite/r/mysqladmin.result
mysql-testsuite: /usr/lib/mysql-testsuite/t/mysqladmin.test
Glen Solsberry
  • 11,960
  • 15
  • 69
  • 94
10

I use dpkg -S filename for that. It can't search for files that are not installed on your system with it, but it's shipped in all dpkg distros by default while apt-file is not.

You also can look that up for files that are not installed on your system using http://packages.ubuntu.com/ website.

Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
Shnatsel
  • 4,008
  • 1
  • 24
  • 25
  • 1
    Just a comment, but this is a major plus for yum or dnf, over the debian tooling. Finding which package you need to install should not entail firing up a browser. You should be able to search the repositories to which you have subscribed via package management tools. – Richard Green Jun 04 '20 at 08:25