Find out what Debian/Ubuntu package includes a file

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
coreutils: /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
keepass2-doc: /usr/share/doc/keepass2/Chm/help/base/pwgenerator.html
keepass2-doc: /usr/share/doc/keepass2/Chm/help/images/pwgen_adv_excltab.png
pwgen: /usr/bin/pwgen
pwgen: /usr/share/doc/pwgen/changelog.Debian.gz
pwgen: /usr/share/doc/pwgen/changelog.gz
pwgen: /usr/share/doc/pwgen/copyright
pwgen: /usr/share/man/man1/pwgen.1.gz
ruby-password: /usr/share/doc/ruby-password/examples/pwgen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s