If you are managing software on Debian/Ubuntu using apt-get package management, there may be cases where you want to remove or upgrade a software package that contains an existing binary file on your system. So given an existing binary file (e.g., /usr/lib/postgresql/8.4/bin/postgres), how can you find out which package provides the binary file?
This is when apt-file can help you, which is a command-line utility developed for that very purpose. First, install apt-file as follows.
$ sudo apt-file update
In order to find out which package "/usr/lib/postgresql/8.4/bin/postgres" belongs to, do the following.
The above output tells you that the binary file comes from a package called postgresql-8.4.
To remove the found package, as well as its dependencies that were installed along with it but are no longer used by anything else on the system, do the following.
Subscribe to Xmodulo
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.