OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

8.3.1. Configuring APT‌


Before we dive into the configuration of APT, let’s take a moment to discuss the configuration mechanism of the Debian system. Historically, configuration was handled by dedicated configura- tion files. However, in modern Linux systems like Debian and Kali, configuration directories with the .d suffix are becoming more commonly used. Each directory represents a configuration file that is split into multiple files. In this sense, all of the files in /etc/apt/apt.conf.d/ are instruc- tions for the configuration of APT. APT processes the files in alphabetical order, so that the later files can modify configuration elements defined in the earlier files.

This structure brings some flexibility to administrators and package maintainers, allowing them to make software configuration changes through file additions without having to change an ex- isting file. This is especially helpful for package maintainers because they can use this approach to adapt the configuration of other software to ensure that it perfectly co-exists with theirs, with- out breaking the Debian policy that explicitly forbids modifying configuration files of other pack- ages. Because of the .d configuration mechanism, you don’t have to manually follow multiple package configuration instructions typically found in the package’s /usr/share/doc/package

/README.Debian file, since the installer can drop in configuration files.


Beware of Configuration While APT has native support of its /etc/apt/apt.conf.d directory, this is not al- Files Generated from .d ways the case. For some applications (like exim, for example), the .d directory is a Directories Debian-specific addition used as input to dynamically generate the canonical configu-

ration file used by the application. In those cases, the packages provide an “update-*” command (for example: update-exim4.conf) that will concatenate the files from the

.d directory and overwrite the main configuration file.

In those cases, you must not manually edit the main configuration file as your changes will be lost on the next execution of the update-* command, and you must also not forget to run the former command after having edited a file out of the .d directory (or your changes will not be used).

Beware of Configuration While APT has native support of its /etc/apt/apt.conf.d directory, this is not al- Files Generated from .d ways the case. For some applications (like exim, for example), the .d directory is a Directories Debian-specific addition used as input to dynamically generate the canonical configu-

ration file used by the application. In those cases, the packages provide an “update-*” command (for example: update-exim4.conf) that will concatenate the files from the

.d directory and overwrite the main configuration file.

In those cases, you must not manually edit the main configuration file as your changes will be lost on the next execution of the update-* command, and you must also not forget to run the former command after having edited a file out of the .d directory (or your changes will not be used).


Armed with an understanding of the .d configuration mechanism, let’s talk about how you can leverage it to configure APT. As we have discussed, you can alter APT’s behavior through command-line arguments to dpkg like this example, which performs a forced overwrite install of zsh:


# apt -o Dpkg::Options::=”--force-overwrite” install zsh

# apt -o Dpkg::Options::=”--force-overwrite” install zsh


Obviously this is very cumbersome, especially if you use options frequently, but you can also use the .d directory configuration structure to configure certain aspects of APT by adding directives to a file in the /etc/apt/apt.conf.d/ directory. For example, this (and any other) directive can

easily be added to a file in /etc/apt/apt.conf.d/. The name of this file is somewhat arbitrary, but a common convention is to use either local or 99local:


$ cat /etc/apt/apt.conf.d/99local

Dpkg::Options {

”--force-overwrite”;

}

$ cat /etc/apt/apt.conf.d/99local

Dpkg::Options {

”--force-overwrite”;

}


There are many other helpful configuration options and we certainly can’t cover them all, but one we will touch on involves network connectivity. For example, if you can only access the web through a proxy, add a line like Acquire::http::proxy ”http://yourproxy:3128”. For an FTP proxy, use Acquire::ftp::proxy ”ftp://yourproxy”.

To discover more configuration options, read the apt.conf(5) manual page with the man apt. conf command (for details on manual pages, see section 6.1.1, “Manual Pages” [page 124]).


Top OS Cloud Computing at OnWorks: