Skip to main content

dpkg-reconfigure: answer the setup questions again

Some packages ask questions while they install, in a blue text screen. If you skipped one, answered it wrongly or pressed Enter too fast, you do not need to reinstall. dpkg-reconfigure asks the questions again and redoes the setup.

sudo dpkg-reconfigure phpmyadmin

Why reinstalling does not help​

The answers are stored by a system called debconf. When you reinstall a package that was only removed (not purged), or run apt install on one that is already installed, debconf already has answers, so no questions are asked and the same wrong setup comes back.

dpkg-reconfigure does three things:

  1. Shows the questions again, with your old answers pre-selected.
  2. Saves the new answers.
  3. Re-runs the package's setup script with them.

Using the blue screens​

KeyDoes
↑ ↓Move between choices
SpacebarTick / untick [*] in a list where you can choose several
TabJump to <Ok> / <Cancel> / <Yes> / <No>
EnterConfirm

The classic mistake: in a checklist (square brackets [ ]), Enter does not tick the item under the cursor. You must press Spacebar first. That is exactly how phpMyAdmin ends up with no web server and a 404.

See the saved answers first​

sudo debconf-show phpmyadmin

Lines with * were answered during install. For phpMyAdmin, look at phpmyadmin/reconfigure-webserver: if it is empty, apache2 was never ticked.

Packages worth knowing​

CommandWhen to use it
sudo dpkg-reconfigure phpmyadmin404 at /phpmyadmin; wrong web server; database setup skipped (phpMyAdmin)
sudo dpkg-reconfigure tzdataThe clock is right but hours off: wrong time zone (Singapore: Asia → Singapore)
sudo dpkg-reconfigure localesperl: warning: Setting locale failed, Cannot set LC_ALL, or odd characters
sudo dpkg-reconfigure keyboard-configurationWrong characters: @ and " swapped, # gives £ (UK layout instead of US). Takes effect after a reboot.
sudo dpkg-reconfigure openssh-serverMake new SSH host keys (after cloning many cards from one image)
sudo dpkg-reconfigure dashRarely needed: which program /bin/sh is

sudo raspi-config → Localisation Options changes time zone, locale and keyboard with menus too; it runs the same tools.

Getting every question​

By default only the important questions are shown. To see all of them:

sudo dpkg-reconfigure -plow phpmyadmin

phpMyAdmin's questions, explained​

QuestionAnswer when fixing a 404
Web server to reconfigure automaticallySpacebar on apache2 → [*], then Tab, Enter
Reinstall database for phpmyadmin?No if phpMyAdmin worked before (keeps its internal database). Yes only to rebuild it.
MySQL application passwordOnly for phpMyAdmin's internal user; not your login

Then sudo systemctl reload apache2 and open http://localhost/phpmyadmin again.

When dpkg-reconfigure itself fails​

MessageFix
Package 'xyz' is not installed and no information is availableInstall it first, or check the spelling with dpkg -l | grep xyz.
xyz is broken or not fully installedsudo dpkg --configure -a, then try again.
The screen flashes past and nothing changesMissing sudo, or the terminal window is too small. Make the window bigger.
Questions are skippedUse -plow to see every question.
debconf: unable to initialize frontend: DialogYou are in a terminal it cannot draw in. Try a normal terminal window or SSH, or add -f readline for plain text questions.

If nothing helps, sudo apt purge PACKAGE deletes the saved answers, and the next sudo apt install PACKAGE asks everything from scratch.