Explore the Debian Packages with Apt-file

November 28, 2014 / FAQs

Apt-file to explore the Debian packages: when one uses only the command line on Linux, there are tools to have in your pocket, so apt-file for exploring the Debian packages (.deb) and finding a package according to a file. Here, we are going to see how to use it:

First, we will see the installation and preparation of apt-file: Apt-file simply installed on Debian via deposits, it will capture the following command.

apt-get install apt-file

It will then prepare apt-file to be used in fulfilling its cache; this requires a simple command line that I’ve mentioned below:

apt-file update

Note: we are updating the apt-file cache for future use:

Therefore apt-file will go read the file /etc/apt/sources.list and fill its cache (twenty megabytes for a basic Debian) to be ready for use. This is of course a command which we will reuse when we will update the file /etc/apt/sources.list

Now we can use apt-file and see what it is capable of!

Listing the files of a Debian package:

The first rather practical thing we do with apt-file list the files that are contained in a Debian package (.deb). For your information a Debian package is a set of files that contains config, script, information storage, etc… files placed in a package and ready to deploy.

With Apt-file, we able to view the files that deployed during the installation with the apt-get installed before the actual installation. More simply, you can perform the following command to view the files contained in the Debian package fail2ban.

apt-file show fail2ban

Note: Apt-file gives us the files contained in the package Fail2ban.

This shows that different files placed in / etc / default, but also in the / etc / fail2ban /, etc…

Finding the package file

A second interesting enough action performed with apt-file. It can in fact find, from a file selected, the package Debian associated with it. If one wishes to know which package is installed on another server for precise control, one just goes on to that server with the following command:

apt-file search /usr/bin/htpasswd

Note: command “htpasswd” supplied with apache2). And the option “search” in apt-file retrieves the packet associated with a file or command. This shows that the controller and tool “htpasswd” come with the packages apache2-dbg and apache2-utils.

Note: a little tip, when looking for the packer corresponding to a command or file, it’s advisable to put the absolute path to it, it can exclude some results and unnecessary rows in the result. The absolute path to a command found with the option “whereis”. For example:

whereis htpasswd

Note: the “whereis” command is to find the path of an executable.

Additional Options

When using apt-file, several options used to extend the tool’s capabilities. One can for specify a file source.list (containing a Debian repository list) other than the file /etc/sources.list. This may allow a comparison between packets quickly supplied from different repositories or between two files. Sources.list option going to do using “-s” or “–sources.list”.

apt-file show apache2 --sources-list /opt/sources.list.test

One can also specify a precise architecture with the “-a” or “-architecture”:

apt-search /usr/bin/owncloud -a amd64

Apt-file can be very useful in some contexts and it is a tool that is good to know!

Incoming searches related to this post:

  • debian apt-get
  • debian apt sources
  • debian testing apt
  • debian apt mirrors
  • debian apt search
  • debian apt list installed packages
  • debian apt repository
  • debian apt pinning