The use of Debconf is addressed in Debian's packaging policy. Joey Hess, the original developer of Debconf, has posted a detailed tutorial online about how to use it when creating a .deb package. However, even as an ordinary user, you can benefit from looking deeper into Debconf. Once you understand what Debconf does, you can not only take more control when installing a Debian-based system, but also configure many of the key subsystems of the operating system more quickly and easily than by editing configuration files.
According to Hess, "Debconf was basically the first step in cleaning up Debian's installation and upgrade process" -- a step that has since been followed by an improved installation program. "I was closely involved in dealing with many of the problems Debian had in these areas at the time," Hess adds, "and it became clear that a lot of problems could only be solved by something like Debconf, and that creating it would open up a lot of new avenues for Debian."
Stripped to its essentials, Debconf is a database of questions with a front end for users. It is not a registry of settings, and does not make changes to the operating system itself. Instead, Debconf is invoked by the config script in a Debian package, and stores the user's answers for the postinst (post-install) script in the package to use. The questions for each package are stored in a .templates file in the package, and the same templates, with their current answers, are available in /var/lib/dpkg/info. Common packages may share the same template file to simplify configuration. Questions are generally prefaced with an explanation of the choice being made, and, in some cases, a button is provided for users to move back in the list of questions to correct mistakes.
Using Debconf during configuration
During installation, Debconf opens soon after packages start to be configured. For many novice users, Debconf induces panic. At first glance, Debconf may seem to be offering more choices and more complexity than newbies feel competent to handle. These questions give Debian part of its reputation for being difficult to install, yet, in fact, Debconf is not nearly as intimidating as it appears.
Most Debconf questions have a default answer that, if you accept it, should give you a functional, although not necessarily optimized, system. The exceptions are hardware detail, such as the driver for a video card or the monitor resolution, which are available elsewhere, and advanced settings for packages such as Apache, which novices are unlikely to install unaided anyway.
One of the settings for Debconf itself is the priority of questions that you want to answer: low, medium, high, or critical. While medium is the default, inexperienced users can chose "critical" so that they are not disturbed by any questions except the few that are absolutely essential in order for the system to work. Conversely, experts can choose "low" to control every possible aspect of package configuration. With these settings, all users can choose the degree of control they prefer.
Still another setting for Debconf itself is the interface. By default, Debian uses what its menu describes as the Dialog interface, a series of text-based boxes similar to those used in the installation program. However, users can also interact with Debconf through GNOME or KDE interfaces, as well as through Readline, or lines of text in the shell, or Editor, which opens a file in Vim for you to change settings. If you have selected one of these interfaces and it is unavailable for some reason, Debconf reverts to its default instead.
Reconfiguring with Debconf
Once your Debian system is installed, Debconf becomes a means of reconfiguring your system. "The funny thing," Hess says, "is that DebConf was never intended to allow that. Then one day I realised that the way things worked allowed [reconfiguration] with essentially no other changes to Debian."
Today, Hess adds, the ability to reconfigure is probably the most popular feature of Debconf. If you are an advanced user, you may prefer editing configuration files directly, but if you are a new user who just wants to adjust your system or make it aware of a new piece of hardware, Debconf is a reliable shortcut.
You can see which packages use Debconf by entering the command
grep Package:\\\|Depends:.*debconf /var/lib/dpkg/status
If you want to view the current configuration for a particular package, log in as root and enter the command
debconf-show packagename. In response, Debconf will list the settings using asterisks as bullets. If no settings are returned, then either the package doesn't use Debconf or, possibly, it is set up to use Debconf but doesn't do so in the current version.
To reconfigure a program or system element, enter the command
dpkg-reconfigure packagename or system setting as the root user. The command opens the same Debconf dialog that was used when the package was first installed. Generally, the same considerations apply as during the installation. The only difference is that, instead of the original defaults, Debconf now uses the settings selected when the package was installed. If you are experimenting, you should note these settings in case you need to restore the system.
Not every package on a Debian system uses Debconf. However, Debian policy encourages its use, and the average desktop installation probably includes a minimum of 60 packages that Debconf can reconfigure. A server installation or a developer's desktop could have up to 10 times as many. On most systems, the parameters for completing dpkg-reconfigure should include many of the basic settings for the operating system:
- debconf: the interface and the priority level of the questions to answer
- xserver-xorg: monitor, video card, and pointing device settings
- linux-image-kernelversion: a Debian kernel installed using the configuration file of the system's original kernel, instead of from source
- etherconf: network and Internet settings
- locales: the languages supported by the system
- console-data: the keyboard mappings supported by the system
- passwd: password settings
- fontconfig: system font configuration
If you prefer, you can also use an interface for reconfiguring debconf settings. The configure-debian package provides a text-based interface that conveniently divides packages using debconf into 18 different categories, such as admin and X11, to make them easier to find. By contrast, gkdebconf provides a graphical interface that is convenient for browsing package settings, but falls back on Debconf itself when you reconfigure. Neither, however, offers any advantage over dpkg-reconfigure except the comfort of an interface.
Every part of a Debian system is not configurable through Debconf. For example, the Advanced Linux Sound Architecture (ALSA), which delivers sound to the desktop, has its own configuration tool called alsaconf for selecting a driver for a sound-card -- although, confusingly, the basic alsa package itself has a setting that can be configured through Debconf. Nor is the Common Unix Printing System (CUPS) configurable through Debconf. Hess notes that Debconf is currently not ideal for partitioning, installation programs, or large-scale installs either, although he hopes that recent efforts to extend it "will eventually make Debconf more usable for these types of configuration." Moreover, for desktop users, Debconf may be increasingly replaced by graphical tools that are even easier to use.
Yet Debconf remains a useful tool. Unlike desktop alternatives, it is always available from the command line, so it can be used to repair a system unable to start the X Window System. Even more importantly, Debconf frequently offers a degree of control that desktop configuration tools do not.
Most of the time, you probably won't need Debconf. However, if you ever let your enthusiasm for experimentation break your system, you may find that Debconf's ability to reconfigure makes it second only to apt-get and dpkg in Debian's arsenal of unique tools.
Bruce Byfield is a course designer and instructor, and a computer journalist who writes regularly for NewsForge, Linux.com and IT Manager's Journal.