How to fix E: Sub-process /usr/bin/dpkg returned an error code (1) in APT
This error occurs when the dpkg package manager encounters a failure during installation, removal, or configuration of packages. It's usually caused by interrupted installations, broken dependencies, or corrupted package databases.
Quick fix
Fixes 1
sudo dpkg --configure -a- Reconfigure pending packages with dpkg
- Fix broken dependencies
- Update package lists
- Check and free disk space
sudo dpkg --configure -aE: Sub-process /usr/bin/dpkg returned an error code (1)
What this error means
The dpkg (Debian Package) subsystem is the core package management tool on Debian-based systems (Ubuntu, Debian, Linux Mint, etc.). When apt runs dpkg to install or remove packages, dpkg returns error code 1 to indicate that something went wrong. This is a generic error code that can have multiple root causes - from interrupted installations that left the system in an inconsistent state, to missing dependencies, corrupted package metadata, or even disk space issues preventing completion of the operation.
Typical symptoms
- apt install/upgrade/remove commands fail with the dpkg error message
- Package installation fails midway through the process
- apt commands hang or take unusually long to fail
- Error appears when running apt update, apt install, or apt upgrade
- Unable to install any new packages on the system
Common causes
- Interrupted package installation from previous attempt (power failure, process killed, etc.)
- Broken package dependencies or conflicting package versions
- Corrupted dpkg database or package metadata files
- Insufficient disk space to complete package operations
- Another apt/dpkg process is running simultaneously
- Stale lock files from crashed package manager processes
- Problematic third-party PPA (Personal Package Archive) causing conflicts
How to fix "E: Sub-process /usr/bin/dpkg returned an error code (1)"
The first and most common fix is to reconfigure packages that dpkg couldn't fully process:
sudo dpkg --configure -aThis command tells dpkg to configure all packages that are currently installed but haven't been fully configured yet. The -a flag means "all". This resolves the error in most cases where a previous installation was interrupted.
If dpkg configuration didn't resolve it, fix broken dependencies next:
sudo apt --fix-broken installOr the older syntax:
sudo apt-get install -fThe -f flag stands for "fix broken". This will attempt to install missing dependencies or remove conflicting packages.
Clear the package cache and refresh your package lists:
sudo apt clean
sudo apt updateThe apt clean command removes old cached package files, and apt update refreshes the list of available packages from repositories. This resolves issues caused by corrupted or outdated package metadata.
Verify you have sufficient disk space:
df -hIf any partition (especially /, /var, or /home) shows 100% or near capacity, you need to free space before package operations can complete. Remove old files or uninstall unnecessary packages:
sudo apt autoremove
sudo apt autocleanIf you've identified which specific package is causing the issue, remove it:
sudo apt remove --purge PACKAGE_NAMEReplace PACKAGE_NAME with the actual package name. The --purge flag removes configuration files as well, giving you a clean slate. You can find the problem package name in the apt error output.
As a last resort, if lock files are preventing operations:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*Then update your package lists:
sudo apt updateBe careful with this approach as it removes lock files that coordinate package operations.
Advanced notes
If the standard fixes don't work, check the detailed dpkg and apt logs for specific error messages:
# View recent apt operations
sudo nano /var/log/apt/history.log
# View dpkg status
sudo cat /var/log/apt/term.logFor corrupted package configuration, you can manually remove problematic package info:
sudo ls -l /var/lib/dpkg/info | grep PACKAGE_NAME
sudo rm /var/lib/dpkg/info/PACKAGE_NAME.*Avoiding PPA Issues: If this error started after adding a third-party PPA, the PPA may have broken dependencies. Remove it with:
sudo add-apt-repository --remove ppa:username/ppa-name
sudo apt updateFor production systems, always test package changes in a staging environment first. Keep regular backups before major system updates.
Frequently asked questions
- What does "1" mean?
- ). When apt runs dpkg to install or remove packages, dpkg returns error code 1 to indicate that something went wrong. This is a generic error code that can have multiple root causes - from interrupted installations that left the system in an inconsistent state, to missing dependencies, corrupted package metadata, or even disk space issues preventing completion of the operation.
- How do I fix "1"?
- This error occurs when the dpkg package manager encounters a failure during installation, removal, or configuration of packages. It's usually caused by interrupted installations, broken dependencies, or corrupted package databases.
- What causes "1"?
- Interrupted package installation from previous attempt (power failure, process killed, etc.) Broken package dependencies or conflicting package versions Corrupted dpkg database or package metadata files
- Is the "1" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.