One of the most disruptive errors encountered when managing packages on Ubuntu and Debian distributions is: Sub-process /usr/bin/dpkg returned an error code (1). This error indicates that the low-level package manager (dpkg) failed while configuring, unpacking, or finalizing software packages during an apt install or apt upgrade command. Resolving this issue clears broken package locks, repairs corrupted package info files, and restores smooth software updates.
Why Does dpkg Fail with Error Code (1)?
Because dpkg handles low-level package unpacking and installation scripts (such as preinst and postinst), the error code (1) triggers due to several specific failures:
- Interrupted Installation: An unexpected power loss, network dropout, or forced terminal termination (Ctrl + C) while installing packages leaves dependencies in a half-configured state.
- Corrupted dpkg Info Database: Residual or damaged status files inside
/var/lib/dpkg/info/prevent package maintenance scripts from completing. - Conflicting Third-Party Repositories: Overwriting shared binaries across differing PPA builds causes file collision blocks.
Step 1: Reconfigure Broken Half-Installed Packages
The first troubleshooting step is instructing dpkg to retry configuring any half-installed software packages:
sudo dpkg --configure -a
If dpkg was interrupted midway through an earlier package update, this single command often completes pending configuration scripts and resolves the error.
Step 2: Force APT to Fix Broken Dependencies
If the error was caused by missing or damaged package dependencies, run APT’s built-in dependency correction command:
sudo apt --fix-broken install
APT will inspect your dependency tree, download any missing prerequisites, and remove orphan files blocking package registration.
Step 3: Remove the Offending Package’s Info Files
If the terminal output indicates a specific package (such as package-name) whose post-installation script failed, its metadata files inside the dpkg database may be corrupt. Back up and isolate the offending files:
- Move the package’s configuration files out of the active dpkg directory:
sudo mv /var/lib/dpkg/info/package-name.* /tmp/ - Update your package list cache:
sudo apt update - Reinstall or remove the package cleanly:
sudo apt install --reinstall package-name
Step 4: Clean the Local APT Cache
Corrupted cached .deb installer files in your local storage can cause repeated checksum and unpacking failures. Clear out cached archive binaries and remove obsolete dependencies:
sudo apt clean
sudo apt autoclean
sudo apt autoremove --purge
Step 5: Overwrite File Collisions (When Binaries Overlap)
If the error message explicitly states that an incoming package tries to overwrite a file already owned by another package, force dpkg to overwrite the shared path:
sudo dpkg -i --force-overwrite /var/cache/apt/archives/package-name.deb
sudo apt --fix-broken install
Step 6: Verify Package Database Health
After performing these repairs, confirm that your APT package management system is fully functional without remaining errors:
sudo apt update && sudo apt upgrade -y
Applying these structured recovery steps clears corrupted package states, restoring full stability and package management reliability across your Ubuntu operating system.