An Introduction to Debian’s Configuration Engine
Debian’s package management system is easily Linux’s most popular, powering Debian, Ubuntu, Linux Mint, MX Linux, and a host of other Debian-derivatives. The DEB package format contains far more than just the software binary files. It contains a wide assortment of control files that tell the package manager about software dependencies, start and stop instructions for daemon control, versions, license, authors, and a digital signature to guarantee integrity and authenticity.
These control files can be setup by the software publisher or maintainer to prompt the user for important configuration variables. These options save the user considerable time by keeping them from the sometimes tedious task of editing possibly multiple configuration files. If you’re a frequent user of Debian or its derivatives, you have probably seen screens (either text or graphical) asking for configuration details after installing a new or updated package.
Configure it Again, Apt
These scripts just aren’t meant for install time, either. If you wish to reconfigure the package, you can run:
Where package-name is the name of the package. If a configuration profile is present, you will be presented with those options again and given a chance to make changes.
For example, on a new Debian install, I run:
To configure the text terminal console font, size, and character set. It’s far easier than setting these items manually.
Automation, Automation, Automation
Configuration prompts are great if you are interacting as a knowledgeable user, but in some cases, particularly in automation or scripting, you don’t want to prompt the user at all. In this case, quieting the configuration prompts is likely advantageous. To do this, run your apt command with the environment variable specified before it.
In this case, all configuration questions will be prompted and either the default selected (if specified), or, if not provided, no configuration will be performed on the package. The -q switch prevents messages from being displayed, and the -y switch answers yes to perform the installation or upgrade unattended.
To make the environment variable persist for your session, run:
Once you log out or exit your shell, the environment variable will disappear or reset to the default. If you want to set it permanently, you can add it to your .bashrc or .zshrc file, however I don’t recommend this because you may miss important configuration questions in the future. That said, if you intend for the Debian system to never require user configuration, this may be desirable.
Preserving Configuration Files
During package installation or upgrade, Debian may wish to prompt the user on overwriting a configuration file. This preference can be appended to the installation command.
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
In this command, the installer is told to quiet any messages, assume yes, and then upgrade configuration files if no changes are present in the new package. If a previous configuration file is present, create a new file and don’t overwrite the old one.
If you don’t care about the configuration file and want to overwrite it, you can use:
Take care when using this option If you’re not absolutely certain that you don’t need the existing configuration and something goes wrong, you can create significant issues on your system or lose access to a remote system upon reboot or service restart.
Changing the Frontend
Though the primary purpose of this article is to explain the noninteractive switch, there are other parameters you can specify for DEBIAN_FRONTEND.
Do not ask any questions and assume the defaults.
Presents the user with the familiar text gray window on blue background. This is the default.
This removes the dialog interface and asks the configuration questions in a pure text-based format. This is well suited for slow connections or terminal emulators that don’t cooperate well with the dialog-based input and windowing system.
Prompts the user graphically using the GTK libraries. This may not work correctly on KDE. Also requires the package cdebconf-gtk and gkdebconf to be installed before use.
I hope this guide has helped you with your system administration and automation tasks through use of the DEBIAN_FRONTEND environment variable.