debconf and dpkg-reconfigure

debian 13 / published / guide #40 / ≈ 3 min read

When you install a Debian package that needs to ask you a question — your timezone, where to install grub, which mail server to set up — you've met debconf. It's the dialog system Debian packages use to gather configuration during install. This guide is the friendly tour: what debconf is, how to answer its questions again later, and how to silence it for unattended installs.

The two pieces

  • debconf — the system. Holds the answers you gave, in a database under /var/cache/debconf/.
  • dpkg-reconfigure — the command that re-runs a package's questions so you can change your answers.

The most useful command

sudo dpkg-reconfigure tzdata

That brings up the timezone-picker menu you saw at install time. Pick a new region and city; the system clock and /etc/timezone update accordingly. No package upgrade or reinstall needed.

Other common dpkg-reconfigure targets

sudo dpkg-reconfigure locales                    # add or change languages
sudo dpkg-reconfigure keyboard-configuration     # keyboard layout (then run setupcon)
sudo dpkg-reconfigure console-setup              # console font and size
sudo dpkg-reconfigure unattended-upgrades        # toggle automatic security updates
sudo dpkg-reconfigure postfix                    # mail server setup
sudo dpkg-reconfigure grub-pc                    # re-run grub bootloader questions
sudo dpkg-reconfigure tzdata                     # timezone

If you're not sure what a package is called, dpkg -l | grep something finds it.

Change the dialog style

By default debconf uses a friendly text menu (the blue dialogs). You can switch the look globally:

sudo dpkg-reconfigure debconf

It asks for your preferred frontend:

  • dialog — full-screen menus (the default).
  • readline — plain text prompts. Best for SSH on slow terminals.
  • noninteractive — don't ask, use defaults. For automated installs.
  • gnome / kde — graphical dialogs on a desktop.

And a priority threshold — which level of questions to actually show: critical, high, medium, low. Set to medium on a workstation if you want to see more decisions.

Silent installs (for scripts / Ansible / cloud-init)

To install a package without it ever stopping to ask anything:

sudo DEBIAN_FRONTEND=noninteractive apt -y install postfix

That tells debconf to use noninteractive mode and accept defaults. Combine with -y on apt to also auto-confirm "do you want to install?".

Pre-seeding answers (the next level)

You can write a file that pre-fills every debconf question for a package, then install it silently with those answers. This is how Debian's automatic installer (preseed) works.

See the answers a package would ask:

sudo debconf-get-selections | grep postfix

(You may need to install debconf-utils first: sudo apt install debconf-utils.)

Set an answer in advance, before installing:

echo "postfix postfix/mailname string mail.example.com" | sudo debconf-set-selections
echo "postfix postfix/main_mailer_type select Internet Site" | sudo debconf-set-selections
sudo DEBIAN_FRONTEND=noninteractive apt -y install postfix

postfix installs silently with your chosen mailname and type.

Save / restore the whole debconf database

Useful when cloning a setup:

sudo debconf-get-selections > my-debconf.txt          # export
sudo debconf-set-selections < my-debconf.txt          # import on the new machine

"Wait, where did my answers go?"

debconf only governs configuration at install time. Many programs then ship their own config files in /etc/ that you can edit normally — debconf doesn't re-touch them on later upgrades. If you reconfigure a package and nothing changes, the answer probably already landed in a normal config file. Check /etc/ for it.

The one thing to remember

If you ever installed a Debian package and wish you could go back to the questions: sudo dpkg-reconfigure packagename. That single command is what 90% of "where do I configure this?" reduces to.

← back to index