6

As far as I understand, the /etc/apt/apt.conf file of Squeeze has been broken into separate files within the /etc/apt/apt.conf.d/ directory in Wheezy.

The debian wiki has not been updated yet and it seems to contain info only about /etc/apt/apt.conf.d/70debconf.

In any case, I am not entirely familiar with configuring apt, besides merely editing /etc/apt/sources.list and I am kinda lost here. The directory structure on my machine is:

/etc/apt/apt.conf.d/
  00aptitude
  00CDMountPoint
  00trustcdrom
  01autoremove
  20listchanges
  20packagekit
  70debconf

and my questions are:

  1. What do these files do?
  2. What do the numbers mean?
  3. Can I add new files to this dir so that they are loaded as well? If so, is there a convention for doing so?
terdon
  • 242,166
alekosot
  • 1,105
  • The Debian wiki has this note: "ToDo: /etc/apt/conf file no longer exists (at least in testing), the configuration is now modular and the topic should be extended specifically we are talking here about /etc/apt/apt.conf.d/70debconf file" so I guess they do the same thing that apt.conf did, just split into separate files. In a similar way as /etc/apt/sources.list.d or /etc/X11/xorg.conf.d. – terdon Nov 14 '13 at 13:27

2 Answers2

4

Quoting The Debian Administrator's Handbook

... it is possible to configure certain aspects of APT by adding directives in a file of the /etc/apt/apt.conf.d/ directory.

and a little further down:

... all of the files in /etc/apt/apt.conf.d/ are instructions for the configuration of APT. APT includes them in alphabetical order, so that the last ones can modify a configuration element defined in one of the first ones.

Joseph R.
  • 39,549
4

This is a typical .d configuration directory. These directories replace or extend a configuration file so that you or a package maintainer can modify the configuration of a program without having to edit a central configuration file.

It's useful because it splits a configuration file into smaller, more manageable chunks which in turn makes it easier for packages to extend the configuration of programs. For example, imagine that you're a package maintainer, and your package has to extend /etc/apt/apt.conf with some configuration directives. Now you have to worry about changes the user or other packages may have made to this file - you must be careful not to overwrite or break these changes, and in turn you have to expect that other changes may break your directives.

.d directories make this much easier. You just put your directives into a file /etc/apt/apt.conf.d/20my-package-name.conf, and you're mostly done.

What do these files do?

Each file adds its own configuration directives to the apt configuration. You'll have to look into each file if you want to know what it does exactly.

What do the numbers mean?

The files are read in alphabetical order, so you can prepend numbers to the file name if you prefer them to be read in a specific order. For example, if later directives overwrite earlier ones (that of course depends on the respective program that reads those files), you could use a low number like 00 to supply default values, a number in the middle like 20 or 40 for normal directives, and a high number like 90 to supply important directives that must overwrite all earlier directives.

Can I add new files to this dir so that they are loaded as well?

Yes, that's the idea of it.

If so, is there a convention for doing so?

Depends on the program, but essentially it's just

  • use a unique name
  • if there's an ordering system, choose a sensible number
  • some programs only read files with a specific extension, so look at the other files to determine the correct extension
  • be careful not to leave any junk files in the directory (for example old backups or temporary files), because those may break the application if it includes every single file in the directory
  • 1
    Changed the accepted answer to this one. It answers my questions in detail and with clarity, and I think it is generally more helpful. – alekosot Oct 14 '17 at 19:25