Fix "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a'"
Do exactly what the message says, then let apt fix any remaining dependencies:
sudo dpkg --configure -a
sudo apt -f install
sudo apt update && sudo apt upgrade
If dpkg --configure -a itself prints an error, the problem is a specific package; the sections below show how to read and fix it.
What the error means
Any apt command (install, upgrade, even apt autoremove) refuses to run and prints:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
Installing a .deb happens in two stages: unpack (copy files into place) and configure (run the package's post-install script, set up services, rebuild caches). dpkg records each package's state in /var/lib/dpkg/status and keeps a journal in /var/lib/dpkg/updates/. If the process stops between or during those stages, packages are left "unpacked" or "half-configured" and apt will not start a new transaction until the old one is finished. dpkg --configure -a resumes it.
Cause 1: the upgrade was interrupted
The usual story: the laptop ran out of battery, you closed the terminal or SSH session, you pressed Ctrl+C, or you rebooted while "Software Updater" or unattended-upgrades was running. In all these cases the quick fix above is the complete solution. Run it from a terminal you will not close; over SSH, start tmux or screen first so a dropped connection does not interrupt it again.
Check that everything is consistent afterwards:
sudo dpkg --audit # lists packages still not fully installed
dpkg -l | grep -v '^ii' # anything not in the normal "ii" state
No output from dpkg --audit means the database is clean. Lines starting with iU (unpacked) or iF (half-configured) are still broken.
Cause 2: a package fails to configure
If dpkg --configure -a ends with something like:
dpkg: error processing package nvidia-dkms-580 (--configure):
installed nvidia-dkms-580 package post-installation script subprocess returned error exit status 10
Errors were encountered while processing:
nvidia-dkms-580
then the interruption was not the whole story: one package's setup script fails. Scroll up to the first error line for that package; it usually says why. The most common cases are a DKMS kernel module that does not build against the new kernel, a service that fails to start, and a full disk. These are covered in detail on the "dpkg returned an error code (1)" page. Fix the underlying cause, then run sudo dpkg --configure -a again.
Cause 3: the disk or /boot is full
Kernel updates write a new kernel and initramfs to /boot. If /boot is a small separate partition, or the root filesystem is full, the update dies part-way through. Check:
df -h / /boot /boot/efi
If /boot is at or near 100%, remove old kernels you are not booted into (check yours with uname -r), then resume:
dpkg -l 'linux-image-*' | grep ^ii
sudo apt purge linux-image-6.8.0-31-generic # an old one, never the running kernel
sudo dpkg --configure -a
If apt refuses to purge because of the interrupted state, use sudo dpkg --purge on the old kernel image packages directly. For a full root filesystem, see "No space left on device".
Cause 4: dpkg is waiting for input
If dpkg --configure -a appears to hang, it is often waiting for you. A configuration file prompt looks like this, and may be hidden behind other output:
Configuration file '/etc/ssh/sshd_config'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
The default action is to keep your current version.
*** sshd_config (Y/I/N/O/D/Z) [default=N] ?
Answer it (pressing Enter keeps your version). Kernel module builds through DKMS can also take several minutes with no output. To see what is actually running:
ps -ef --forest | grep -A6 '[d]pkg'
Cause 5: the system will not boot after the interruption
If the interruption happened during a kernel, systemd or libc update, the desktop may not start. Boot an older kernel or recovery mode from the GRUB menu (hold Shift on BIOS machines or press Esc on UEFI during boot), open a root shell and run:
mount -o remount,rw /
dpkg --configure -a
apt -f install
update-grub
reboot
Ubuntu 26.04 builds the initramfs with Dracut. If the kernel package failed while generating it, regenerate it after the repair with sudo dracut --force --kver $(uname -r), or for every installed kernel with sudo dracut --force --regenerate-all. Debian 13 and Ubuntu 24.04 use initramfs-tools: sudo update-initramfs -u -k all. If GRUB itself is damaged, see the GRUB rescue guide.
Distro-specific notes
- Ubuntu release upgrades: if
do-release-upgradewas interrupted, run the quick fix, thensudo apt full-upgradeto complete the remaining packages. The Ubuntu upgrade guide lists post-upgrade checks. - Linux Mint: the Update Manager shows the same error in a dialog; the terminal commands are identical.
- Fedora (DNF5) and openSUSE use RPM, which does not have a separate configure stage. After an interrupted transaction, run
sudo dnf distro-syncorsudo zypper verify. On Arch, rerunsudo pacman -Syu; if it complains about a lock, see pacman "unable to lock database".
How to prevent it
- Plug in laptops before large upgrades and do not close the updater window.
- Run upgrades over SSH inside
tmuxorscreen. - Keep
/boottidy withsudo apt autoremove, which removes old kernels automatically. - Do not kill apt or dpkg to get rid of a lock; see "Could not get lock" for the safe way.
Frequently asked questions
What does dpkg --configure -a do?
It runs the configuration step (the package's postinst script) for every package that was unpacked but not configured. It does not download anything and it is safe to run repeatedly.
dpkg --configure -a seems stuck. What should I do?
It is often waiting for an answer to a configuration prompt or building a kernel module. Check the terminal for a question, and run ps -ef --forest | grep -A5 dpkg in another terminal to see which script is running before you interrupt anything.
Can I run dpkg --configure -a from recovery mode?
Yes. Boot the "Advanced options" GRUB entry, pick recovery mode, choose dpkg (Repair broken packages) or drop to a root shell, run mount -o remount,rw /, then dpkg --configure -a.
Will I lose data if dpkg was interrupted?
Your personal files are not affected. The risk is that some system packages are half-installed, which dpkg --configure -a and apt -f install normally repair.
Spotted a mistake or a command that no longer works? Send a correction — pages are re-checked when reports come in.