Updated: 22 October 2026 · Applies to: Debian 13 (dpkg 1.22.22, apt 3.0.3), Ubuntu 24.04 and 26.04
To change the answers you gave when a package was installed, run sudo dpkg-reconfigure PACKAGE. To uninstall a package, run sudo apt remove PACKAGE (keeps its configuration files) or sudo apt purge PACKAGE (deletes them too). With dpkg alone, the same two actions are dpkg -r and dpkg -P.
Reconfigure an installed package with dpkg-reconfigure
Many Debian and Ubuntu packages ask questions during installation (time zone, locale, web server to configure and so on). The answers are stored by debconf, and dpkg-reconfigure asks them again and applies the new answers.
- See the answers a package has stored.
debconf-showcomes with debconf, so it is always there:sudo debconf-show tzdata
Output (a fresh Debian 13 system, cut to the lines marked with a star, which are the questions that have been answered):
* tzdata/Areas: Etc * tzdata/Zones/Etc: UTC
- Run the questions again:
sudo dpkg-reconfigure tzdata
In a normal SSH session you get a text menu (the dialog frontend). Use the arrow keys to choose, Tab to move to Ok and Enter to confirm. When it finishes, the package applies the new setting straight away. For tzdata on our Debian 13 test system:
Output:
Current default time zone: 'Europe/Amsterdam' Local time is now: Thu Oct 22 15:22:44 CEST 2026. Universal Time is now: Thu Oct 22 13:22:44 UTC 2026.
Useful dpkg-reconfigure options
-f FRONTEND(--frontend) picks the interface:dialog,readline,teletype,editorornoninteractive.-f teletypeshows plain numbered lists, which is handy over a slow connection or in a serial console. On a minimal system without the fullperlpackage, readline is not available: debconf printsunable to initialize frontend: Readlineand falls back to another frontend.-p PRIORITY(--priority) shows only questions of that priority or higher:low,medium,highorcritical. dpkg-reconfigure shows all questions (low) by default.--forcereconfigures a package that is in a broken or half-configured state. Note that-fis the frontend option, not force (older guides mix them up). If a package is broken because an install was interrupted, see How to Recover an Interrupted dnf or apt Package Transaction first.
To change the default frontend for all packages, reconfigure debconf itself:
sudo dpkg-reconfigure debconf
Reconfigure without any questions (scripts)
Make the change in the package's own file first, then let the package pick it up with the noninteractive frontend. For the time zone:
sudo ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime sudo dpkg-reconfigure -f noninteractive tzdata
Output:
Current default time zone: 'Asia/Kolkata' Local time is now: Thu Oct 22 18:52:35 IST 2026. Universal Time is now: Thu Oct 22 13:22:35 UTC 2026.
To pre-answer questions for an automated install, export the stored answers with debconf-get-selections (package debconf-utils) and load them on another server with debconf-set-selections. For time zones in particular, How to Check and Change the Timezone on Debian and Ubuntu covers timedatectl too.
Uninstall a package: remove or purge
- Remove the program but keep its configuration files (useful if you plan to reinstall it):
sudo apt remove screen
- Check the state.
rcmeans "removed, configuration files still present":dpkg -l screen
Output:
rc screen 4.9.1-3 amd64 terminal multiplexer with VT100/ANSI terminal emulation
- Remove the program and its configuration files (also works after a plain remove):
sudo apt purge screen
Output (shortened):
REMOVING: screen* ... Purging configuration files for screen (4.9.1-3) ...
That is the layout of apt 3 (Debian 13, Ubuntu 26.04); apt 2.8 on Ubuntu 24.04 prints "The following packages will be REMOVED" instead, with the same result. The
*after the name means the package is purged. Afterwardsdpkg -l screensaysno packages found matching screen. - Remove the libraries that were installed only as dependencies and are no longer needed:
sudo apt autoremove
On our test system, removing
tmuxleftlibevent-core-2.1-7t64andlibjemalloc2behind, andapt autoremoveremoved both. Read the list before you confirm.
Purge deletes the package's configuration files. What happens to data the program created, such as a database server's data directory, depends on the package, so back up first.
To purge every package that is in the rc state at once, use an apt pattern:
sudo apt purge '~c'
Uninstall with dpkg (-r and -P)
dpkg is the low-level tool under apt. It removes exactly the package you name and never removes dependencies for you.
sudo dpkg -r screen
sudo dpkg -P screen
-r (--remove) keeps the configuration files, -P (--purge) deletes them. Two things to know:
- Use the package name, not the .deb file name. If you installed a downloaded file, read the name from it with
dpkg-deb -f FILE.deb Package. With the file name, dpkg stops with:dpkg: error: you must specify packages by their own names, not by quoting the names of the files they come in
- dpkg refuses to remove a package that another installed package needs:
dpkg: dependency problems prevent removal of libevent-core-2.1-7t64:amd64: tmux depends on libevent-core-2.1-7t64 (>= 2.1.8-stable). dpkg: error processing package libevent-core-2.1-7t64:amd64 (--remove): dependency problems - not removing
Remove the dependent package first, or use
apt remove, which lists everything it will remove together.
Not sure of the exact package name? How to List Installed Packages on Ubuntu and Debian shows how to find it, and How to Find Where a Package Installed Its Files shows which files belong to it.
Can you uninstall dpkg itself?
No, not safely. dpkg is an essential package: apt and every other package tool depend on it. A dry run (apt-get -s remove dpkg) on Debian 13 shows the warning apt gives:
WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! dpkg
If dpkg is giving errors, repair it instead of removing it: sudo dpkg --configure -a finishes interrupted installs, and sudo apt --fix-broken install fixes missing dependencies.
Related: How to Install a .deb File on Debian and Ubuntu (apt, dpkg, gdebi).
Official documentation: dpkg-reconfigure, dpkg, apt.