LinuxCommandLibrary

dpkg-preconfigure

Preconfigure packages before installation

SYNOPSIS

`dpkg-preconfigure [options] package...`

Note: Most configuration behavior is controlled via debconf environment variables rather than direct command-line options for `dpkg-preconfigure` itself.

PARAMETERS

--help
    Display help message and exit.

--version
    Show version information and exit.

DESCRIPTION

dpkg-preconfigure is a utility used within the Debian package management system to interact with debconf. Its primary purpose is to ask configuration questions for packages before their installation or upgrade. This is crucial for enabling non-interactive installations, particularly in automated environments or scripts.

When a package is installed, it may need user input for various settings (e.g., time zone, default services, network configurations). debconf handles these questions using templates defined by the package. dpkg-preconfigure orchestrates this process: it reads these templates, presents the questions via a chosen frontend (e.g., dialog, readline, noninteractive), and stores the answers in the debconf database. This pre-configuration ensures that the actual `dpkg` installation step does not halt waiting for user input, making the entire process smoother and scriptable. It is typically called by higher-level tools like `apt` or `apt-get` as part of their installation routines.

CAVEATS

dpkg-preconfigure relies heavily on the DEBIAN_FRONTEND environment variable to determine how it interacts with the user (e.g., `noninteractive`, `dialog`, `readline`). If DEBIAN_FRONTEND is set to `noninteractive`, debconf will use default answers or previously stored answers, leading to fully automated installations.

It only preconfigures packages that haven't been configured before or whose configuration templates have changed. It won't re-ask questions if satisfactory answers are already stored in the debconf database.

This command does not install the packages; it only performs the configuration questioning phase. The actual installation is handled by `dpkg`.

ENVIRONMENT VARIABLES

The behavior of `dpkg-preconfigure` is largely influenced by debconf environment variables:
DEBIAN_FRONTEND: Controls the type of user interface debconf uses. Common values include `dialog` (default interactive text-based), `readline` (more basic text input), `noninteractive` (no prompts, uses defaults or pre-existing answers), `gnome`, `kde`, `newt`, `web`. Setting this to `noninteractive` is vital for unattended installations.
DEBCONF_NONINTERACTIVE_SEEN: Can be set to 'true' to indicate that debconf should suppress certain warnings or interactive prompts related to non-interactive mode. Typically used in conjunction with DEBIAN_FRONTEND=noninteractive.

TYPICAL WORKFLOW

While you can run `dpkg-preconfigure` manually, it's most commonly invoked automatically by `apt` or `apt-get`. When you run `apt-get install mypackage`, `apt-get` often performs these steps internally (simplified):
1. Calls `dpkg-preconfigure mypackage` to collect configuration answers.
2. Calls `dpkg --install mypackage.deb` using the pre-configured answers.
This ensures a seamless installation without interruptions, even if `mypackage` requires input.

HISTORY

dpkg-preconfigure emerged as a crucial component of the Debian package management ecosystem alongside debconf. debconf was introduced to standardize and streamline package configuration, moving away from disparate shell scripts for prompting users. dpkg-preconfigure specifically addressed the need to collect configuration answers before the package installation process itself, enabling robust automation and consistent deployment, especially in server environments where interactive prompts are undesirable. Its role has remained consistent since its inception as a bridge between the high-level package management tools (`apt`, `apt-get`) and the low-level debconf configuration system.

SEE ALSO

debconf(7), dpkg(8), apt(8), apt-get(8)

Copied to clipboard