Last updated on November 24, 2020 by Dan Nanni
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-get install apt-file $ sudo apt-file update
In order to find out which package
/usr/lib/postgresql/8.4/bin/postgres belongs to, do the following.
$ sudo apt-file search /usr/lib/postgresql/8.4/bin/postgres
The above output tells you that the binary file comes from a package called
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.
$ sudo apt-get autoremove postgresql-8.4