How To Find What Package Provided a File?
Earlier today I found myself in a situation where one Ubuntu machine was missing an executable available on the second. After trying to guess the package name a few times without success I pulled this little number out of my bag of tricks:
cedwards@monkey:~$ dpkg -S $(which host)
bind9-host: /usr/bin/host
As you can see, this returned the package name that provided the executable, host. Using the -S option with dpkg directly is a really simple way to find out what package provided the file or executable you’re looking for.
This requires, of course, that the file exists on the machine you’re running the command on. I should also note that the command-not-found package provides this functionality in recent versions of Ubuntu. If you’re on an Ubuntu variant, or a Debian release that may not provide this service, this is a good tool to be aware of.. just in case.