1. Package installed on the system
Sometimes we need to know which Debian/Ubuntu package installed a specific file so we can remove it from the system. This can be known using the dpkg tool, for instance say you want to find out which package is the ‘ls’ command included in:
# dpkg -S /bin/ls
As seen above, the ‘ls’ system command is included in the coreutils package.
2. Package NOT installed on the system
On the other hand, we might want to install a specific tool on our system but we don’t know the name of the Debian/Ubuntu package.
In this case we’ll use apt-file which will search on the APT repositories configures in the sources.list.
Installing apt-file is straightforward using apt-get:
# apt-get install apt-file
Update its database:
# apt-file update
Finally do some search, for instance ‘pwgen’:
# apt-file search pwgen