How to Fix ‘Sub-process /usr/bin/dpkg returned an error code (1)’ in Ubuntu

Running package installations, system upgrades, or removals in Ubuntu using apt install or apt upgrade only to have the terminal abort with the terminal error: ‘Errors were encountered while processing: package-name’ and ‘E: Sub-process /usr/bin/dpkg returned an error code (1)’ blocks all future package management. In Debian and Ubuntu systems, dpkg error code 1 signals that an installation or post-installation maintainer script (such as postinst or prerm) exited with a non-zero exit code due to broken dependencies, missing configuration files, or corrupted package metadata.

Why Does dpkg Return Error Code 1 in Ubuntu?

When apt downloads a package, dpkg unpacks binaries and executes shell maintainer scripts located in /var/lib/dpkg/info/. Common root causes include:

  • Failing Maintainer Scripts (postinst/prerm): The package configuration script attempting to create system users, start services, or copy configuration files that fail due to missing dependencies.
  • Corrupted dpkg Package Metadata: Damaged .list or .md5sums files in /var/lib/dpkg/info/ preventing dpkg from verifying installed file trees.
  • Unfinished or Interrupted Package Installations: An interrupted terminal session or power cut leaving packages in a half-configured (unpacked or half-configured) state.
  • Conflicting PPA or Third-Party Repositories: Third-party package archives supplying binaries compiled against incompatible shared library versions.
  • Exhausted Storage or Inode Space: A full /boot or /var partition preventing kernel images or database files from writing to disk.

Step 1: Reconfigure Unfinished Packages

Instruct dpkg to resume and complete all pending package configurations.

  1. Open your terminal and execute:
    sudo dpkg --configure -a
  2. If the command completes without errors, try updating your system again:
    sudo apt update && sudo apt upgrade -y

Step 2: Force Dependency Resolution

Use apt’s built-in dependency fixer to download missing prerequisites or safely remove incompatible packages.

  1. Run the fix-broken install routine:
    sudo apt --fix-broken install
  2. Review the suggested removals and dependencies. Type Y and press Enter to proceed.

Step 3: Move Corrupted Package Info Files

If a specific package continually fails due to a broken maintainer script, temporarily isolating its metadata allows dpkg to bypass the failing hook.

  1. Identify the exact package name cited in the error output (e.g. package-name).
  2. Move the package’s info files out of the dpkg database:
    sudo mv /var/lib/dpkg/info/package-name.* /tmp/
  3. Update package lists and reconfigure:
    sudo apt update
    sudo dpkg --configure -a
  4. Reinstall or cleanly purge the package:
    sudo apt install --reinstall package-name

Step 4: Clean the APT Package Cache

Corrupted deb packages stored in local archives can repeatedly fail hash checks and configuration.

  1. Clear obsolete and downloaded deb archives:
    sudo apt clean
    sudo apt autoclean
    sudo apt autoremove -y

Step 5: Check Free Disk and Inode Space

A full /boot partition filled with accumulated old Linux kernel images is a frequent cause of dpkg error code 1 during kernel upgrades.

  1. Inspect available disk space:
    df -h / /boot /var
  2. Inspect available filesystem inodes:
    df -i / /boot /var
  3. If /boot is at 100% capacity, remove obsolete kernel images safely:
    sudo apt autoremove --purge

Reconfiguring pending packages with dpkg, repairing broken dependencies, and removing corrupted maintainer scripts resolves dpkg error code (1) in Ubuntu.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.