What Ubuntu package contains the file I'm trying to install?


I’ve really like how yum has the “whatprovides” keyword.  You can execute

$ yum whatprovides startkde

And yum will search all of the known packages within the installed repositories and return back the package you need to install in order to have the “startkde” binary.  At that point, all thats needed is a

$ yum install <package>

But how do we do this on Ubuntu and other Linuxes which have apt-get and aptitude?

I found that this same functionality can be searched using the “apt-files” package.  So first, lets install apt-files.

$ apt-get install apt-file

Once apt-file has been installed, we need to update its cache.

$ apt-file update

Then, just search for the file you’re looking for.  Here, I’m looking for startkde which is provided by the kde-workspace-bin dpkg.

$ apt-file search startkde

kdebase-workspace-bin: /usr/bin/safestartkde
kdebase-workspace-bin: /usr/bin/startkde
kdebase-workspace-bin: /usr/share/man/man1/startkde.1.gz

So, once I know the package name, its just a quick apt-get install and i’m golden.

$ apt-get -y install kdebase-workspace-bin

$ which startkde /usr/bin/startkde

Nice!  Keep in mind that the cache is stored on the local file system, so updating the cache before issuing a search is always a good idea.

This article was posted by Matty on 2009-07-15 08:37:00 -0400 -0400