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 finds 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 is 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:
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 can do with apt-file is to 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 be deployed.
With Apt-file, we will be able to view the files that will be deployed during the installation with apt-get install 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 will be placed in / etc / default, but also in the / etc / fail2ban /, etc…
Finding the package file
A second interesting enough action can be 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 installed on another server for precise control, can just go 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 can be found with the option “whereis”. For example:
Note: the “whereis” command is to find the path of an executable.
When using apt-file, several options can be used to extend the capabilities of the tool. One can for specify a file sources.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 is going to be done 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