Attempting to install, update, or remove software on Ubuntu can occasionally come to an abrupt standstill with the terminal error: “E: dpkg was interrupted, you must manually run ‘sudo dpkg –configure -a’ to correct the problem.” As long as this error persists, all APT commands (such as apt update, apt install, and apt upgrade) are blocked.
This state occurs when a package installation or kernel upgrade was forcefully interrupted before completion, such as during an unexpected system crash, sudden power outage, accidental terminal closure, or premature laptop shutdown. Because Debian package management requires transactional integrity, dpkg locks the database until pending package scripts are resolved. Follow these steps to restore clean package manager operation.
Run the Recommended dpkg Configure Command
In most instances, executing the command suggested by the error prompt allows dpkg to finish configuring the uncompleted packages.
- Open the Terminal application (Ctrl + Alt + T).
- Execute the manual configuration command with administrative privileges:
sudo dpkg --configure -a - Enter your sudo password when prompted.
- Observe the terminal output as dpkg re-triggers post-installation configuration scripts for pending packages.
- If the process completes without errors, test APT by running:
sudo apt update
Remove Stale Package Manager Lock Files
If running sudo dpkg --configure -a returns an error stating “Could not get lock /var/lib/dpkg/lock-frontend” or “Resource temporarily unavailable,” a background process or dead lock file is blocking access.
- Check if another package manager process (such as unattended-upgrades or Ubuntu Software centre) is actively running:
ps aux | grep -i apt - If processes like
unattended-upgradeare running, allow them several minutes to finish naturally. - If no active installer is running and the system was rebooted, remove the orphaned lock files manually:
sudo rm /var/lib/dpkg/lock-frontend sudo rm /var/lib/dpkg/lock sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/archives/lock - Re-run the configuration pass:
sudo dpkg --configure -a
Repair Broken Package Dependencies with APT
If an interrupted installation left orphaned dependencies or partially downloaded packages in the archive cache, use APT’s automated dependency repair engine.
- Instruct APT to download and resolve missing dependencies:
sudo apt --fix-broken install - If prompted to confirm changes with [Y/n], press Y and Enter.
- Clear corrupted cached deb archive packages from disk:
sudo apt clean - Refresh package indexes from official mirrors:
sudo apt update
Handle Stubborn Packages with Forceful Removal
If a specific package fails repeatedly during dpkg --configure -a due to a faulty post-install script (e.g. error exit status 1 or 2), you can isolate and remove its status definition.
- Identify the failing package name named in the error output (for example,
problem-package). - Remove the package’s status entry file:
sudo rm -f /var/lib/dpkg/info/problem-package.* - Run
sudo dpkg --configure -aagain. The package will now configure cleanly because the corrupted pre/post-install script was removed. - Immediately purge and reinstall the package cleanly:
sudo apt purge problem-package && sudo apt install problem-package
Verify Full System Health and Kernel Integrity
Once dpkg functions normally, complete pending system updates to ensure kernel modules and system libraries are synchronized.
- Run a complete distribution upgrade pass:
sudo apt dist-upgrade -y - Remove orphaned packages no longer needed by the system:
sudo apt autoremove --purge -y - Reboot your system:
sudo reboot.