Anyone who has ever used rpm for package management has at one time or the other had to invoke the command:
rpm -qf PATH_TO_FILE
The above command will tell you what package manages the given file, or more specifically, what package was installed, when it was installed and what put that file on the hard drive. This is an incredibly useful feature when you are debugging a system, attempting to figure out where a file comes from, resolving version conflicts, etc. But many people do not realize that Debian derivatives, such as Ubuntu, also has a similar capability.
In your Debian derivative type:
sudo apt-get install apt-file
This command will install the helpful application apt-file onto your system. Once installed, take a look at its command line options by typing the eponymous command. This is what you will see:
apt-file version 22.214.171.124 (c) 2002 Sebastien J. Grossapt-file [options] action [pattern] Configuration options: --sources-list -s sources.list location --cache -c Cache directory --architecture -a Use specific architecture --cdrom-mount -d Use specific cdrom mountpoint --package-only -l Only display packages name --fixed-string -F Do not expand pattern --ignore-case -i Ignore case distinctions --regexp -x pattern is a regular expression --verbose -v run in verbose mode --dummy -y run in dummy mode (no action) --help -h Show this help. --version -V Show version number Action: update Fetch Contents files from apt-sources. search|find Search files in packages list|show List files in packages purge Remove cache files
As you can see, there are a lot of options. The option you need to mimic the functionality of rpm -qf is the search option. For example, to find out what debian package provides the application gpg simply type:
sudo apt-file search $(which gpg)
When you execute this command you are going to get a lot more results than you probably wanted. That is because the apt-file command does a lazy search and searches for any command that patches the pattern /usr/bin/gpg*. In order to narrow the results, use the –fixed-string option:
sudo apt-file search --fixed-string $(which gpg)
The console should display something similar to the following:
akutz@vault:~$ sudo apt-file search --fixed-string $(which gpg) gnupg: usr/bin/gpg gnupg: usr/bin/gpg gnupg: usr/bin/gpg
I hope this little tutorial on apt-file will make your daily life as a Linux system administrator just a little bit easier!