What does the "dpkg –configure -a" command do?

Why when an installation fails, should I run dpkg --configure -a, to fix it, also, why can’t sudo apt do this?

From the manpage:

--configure package...|-a|--pending
          Reconfigure an unpacked package. If -a  or  --pending  is  given
          instead  of  package, all unpacked but unconfigured packages are
          configured.

          Configuring consists of the following steps:

          1. Unpack the conffiles, and at the same time back  up  the  old
          conffiles, so that they can be restored if something goes wrong.

          2. Run postinst script, if provided by the package.
Answered By: Mitch

apt, aptitude, synaptic etc. are frontends to the same tool: dpkg. dpkg is very low-level, and apt isn’t particularly smart. So if package configuration was interrupted, apt tells you to descend to the lower level to fix it. Note that apt may not be aware of the packages which caused the problem (they may be manually installed local packages, and they may be a hundred packages and not one) and keeping it simple, it tells you to use the tool that is aware of them. Mitch has already posted what this command does.

Answered By: muru
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.