yum whatprovides apt alternatives

December 7, 2020 in Tutorial2 minutes

If you’re using rpm based Linux distribution, most likely you’re familiar with yum whatprovides command. Using this command we can search which packages provides a specific file.

In Ubuntu or Debian-based Linux distribution we can also do similar action using dpkg and apt-file.

Searching File Using dpkg -S

To get which packages provides a specific file we can use dpkg command using -S option. We only need to provide the file name that we want to search.

For example we can search which package providing lscpu using command below.

$ dpkg -S lscpu
util-linux: /usr/share/man/man1/lscpu.1.gz
util-linux: /usr/share/bash-completion/completions/lscpu
util-linux: /usr/bin/lscpu

Searching File Using apt-file

Install apt-file

If apt-file is not installed on your system yet, you can use command below to install apt-file

sudo apt-get install apt-file

Update apt-file database

After installing apt-file we need to update apt-file database using command below

sudo apt-file update

Search file using apt-file

To search the same file lscpu using apt-file command below

$ apt-file search lscpu
fish-common: /usr/share/fish/completions/lscpu.fish
manpages-de: /usr/share/man/de/man1/lscpu.1.gz
manpages-fr-extra: /usr/share/man/fr/man1/lscpu.1.gz
manpages-pl: /usr/share/man/pl/man1/lscpu.1.gz
util-linux: /usr/bin/lscpu
util-linux: /usr/share/bash-completion/completions/lscpu
util-linux: /usr/share/man/man1/lscpu.1.gz

To search for a specific file we can use a full / absolute path of the file. For example

$ apt-file search /usr/bin/lscpu
util-linux: /usr/bin/lscpu

Summary

In this tutorial we learn how to use apt to do similar actions like yum whatprovides does. Hope this is useful and see you next time. Happy Hacking!