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:
- Shows the questions again, with your old answers pre-selected.
- Saves the new answers.
- Re-runs the package's setup script with them.
Using the blue screens
| Key | Does |
|---|---|
| ↑ ↓ | Move between choices |
| Spacebar | Tick / untick [*] in a list where you can choose several |
| Tab | Jump to <Ok> / <Cancel> / <Yes> / <No> |
| Enter | Confirm |
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
| Command | When to use it |
|---|---|
sudo dpkg-reconfigure phpmyadmin | 404 at /phpmyadmin; wrong web server; database setup skipped (phpMyAdmin) |
sudo dpkg-reconfigure tzdata | The clock is right but hours off: wrong time zone (Singapore: Asia → Singapore) |
sudo dpkg-reconfigure locales | perl: warning: Setting locale failed, Cannot set LC_ALL, or odd characters |
sudo dpkg-reconfigure keyboard-configuration | Wrong characters: @ and " swapped, # gives £ (UK layout instead of US). Takes effect after a reboot. |
sudo dpkg-reconfigure openssh-server | Make new SSH host keys (after cloning many cards from one image) |
sudo dpkg-reconfigure dash | Rarely 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
| Question | Answer when fixing a 404 |
|---|---|
| Web server to reconfigure automatically | Spacebar 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 password | Only for phpMyAdmin's internal user; not your login |
Then sudo systemctl reload apache2 and open http://localhost/phpmyadmin again.
When dpkg-reconfigure itself fails
| Message | Fix |
|---|---|
Package 'xyz' is not installed and no information is available | Install it first, or check the spelling with dpkg -l | grep xyz. |
xyz is broken or not fully installed | sudo dpkg --configure -a, then try again. |
| The screen flashes past and nothing changes | Missing sudo, or the terminal window is too small. Make the window bigger. |
| Questions are skipped | Use -plow to see every question. |
debconf: unable to initialize frontend: Dialog | You 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.