5 Simple Ways to Fix “sub-process /usr/bin/dpkg returned an error code (1)”

Written by

Reviewed by

Last updated: July 24, 2024

Expert verified

SVG Image

TL;DR

To fix “sub-process /usr/bin/dpkg returned an error code (1)” in Linux, try these four solutions:

  1. Fix broken dependencies and conflicts using the commands sudo apt-get update && sudo apt-get install -f.
  2. Reinstall problematic packages by running the sudo apt-get install --reinstall <package-name> command.
  3. Check and fix permission issues using the sudo apt-get update command.
  4. Repair the package database by running sudo apt-get clean && sudo apt-get update followed by the sudo apt-get upgrade command.

To know more about how to fix “sub-process /usr/bin/dpkg returned an error code (1)”, read the article below now.

Seeing the error message “sub-process /usr/bin/dpkg returned an error code (1)” when you’re trying to install or update software on your Linux system can be really frustrating. But don’t worry, there are solutions. In this post, I’ll show you how to fix this error by repairing broken dependencies, reinstalling problem packages, checking permission issues, and repairing the package database. I’ll also share tips to prevent this error from happening again, so your Linux system runs smoothly and efficiently.

What is the ‘sub-process /usr/bin/dpkg returned an error code (1)’ Error?

When you install, update, or remove software on your Linux system, a tool called dpkg (Debian Package Manager) handles the process. Sometimes, things can go wrong during these operations, and dpkg can’t complete the task. When this happens, you might see the error message ‘sub-process /usr/bin/dpkg returned an error code (1)’.

Several things can cause this error:

  1. Corrupted Downloads: If a package download gets interrupted or corrupted, dpkg can’t install it properly.
  2. Broken Dependencies: Software packages often rely on other packages to work. If these dependencies are missing or broken, dpkg can’t proceed.
  3. File System Issues: Problems with your file system, such as bad sectors or permission issues, can prevent dpkg from working correctly.
  4. Configuration Errors: Misconfigured system settings or repositories can lead to this error during package management operations.

How Does This Affect Your System?

When this error occurs, it can leave your system in an unstable state. You might not be able to install new software, update existing packages, or even remove unwanted ones. This can be frustrating and can disrupt your workflow.

How to Fix “sub-process /usr/bin/dpkg returned an error code (1)”

To fix “sub-process /usr/bin/dpkg returned an error code (1)”, start by updating your package list and fixing broken dependencies using the command sudo apt-get update && sudo apt-get install -f. Next, reinstall any problematic packages. Check and fix any permission issues that might be causing the error. Finally, repair the package database by running sudo apt-get clean followed by sudo apt-get update.

Here’s a breakdown of each method you can try to fix the error:

1. Fix Broken Dependencies and Conflicts

apt-get is a powerful tool for managing packages on your Linux system. This package is usually pre-installed and can help you resolve the “sub-process /usr/bin/dpkg returned an error code (1)” error. Here’s how you can use it to fix broken dependencies and conflicts:

  1. In the Terminal window, run the command below:
sudo apt-get update && sudo apt-get install -f
  1. This command updates the package database and installs any missing dependencies or packages that are causing conflicts. It may take some time, depending on the size of the package database and the number of packages that need to be installed.
fix broken dependencies and conflicts
  1. Once the command is complete, try running the original apt-get command that caused the sub-process /usr/bin/dpkg returned an error code (1) error in the first place.
  2. If the “sub-process /usr/bin/dpkg returned an error code (1)” error no longer occurs, the issue has been resolved. You can now proceed with installing or upgrading the packages you need. But if the error persists, try the next solution in this guide to resolve this issue.

2. Reinstall Problematic Packages

If the “sub-process /usr/bin/dpkg returned an error code (1)” error is caused by a specific package, consider reinstalling that particular package to fix this error. Here’s how you can do it:

  1. Head to the Terminal app and run any apt-related command. 
  2. Review the error message displayed after the apt command execution. The error message will typically indicate the name of the package that is causing the issue. 
  3. For example, if the error message indicates that the problematic package is called zsh, use sudo apt-get install --reinstall <package-name>. Your command should look like this:
sudo apt-get install --reinstall zsh
  1. Wait for the command to complete. It will take a few minutes to reinstall the problematic package and fix any issues with its dependencies.
reinstall problematic packages to fix sub-process /usr/bin/dpkg returned an error code (1)
  1. Once the command is complete, try running the original apt-get command again. If the error is still there, move on to the next method.

3. Check and Fix Permission Issues

Another solution to fix the “sub-process /usr/bin/dpkg returned an error code (1)” message is to check and fix the permission issues. To do so, follow the steps below:

  1. Launch the Terminal window and execute the command below:
sudo apt-get update
  1. This command updates the package database and checks for any permission issues that may be causing the error.
check and fix permission issues
  1. Once the process is complete, run the original apt-get command again to see if the “sub-process /usr/bin/dpkg returned an error code (1)” message is fixed.

4. Repair the Package Database

Sometimes, this error may occur when the package database becomes corrupted or outdated. If that’s the case, you need to repair the package database. Here’s how to do it:

  1. Type the following command in the Terminal window and press Enter:
sudo apt-get clean && sudo apt-get update
  1. This command will clear the local repository of retrieved package files that are no longer needed and update the package database.
repair package database
  1. Once the process is complete, execute the following command:
sudo apt-get upgrade
  1. This command will upgrade all installed packages on your Linux system to their latest versions.
upgrade all installed packages
  1. Once the command is complete, execute any of the apt-get commands to check whether the error is resolved or not.

5. Cleaning Up Partial Packages

Cleaning up partial packages is an essential step in resolving the “sub-process /usr/bin/dpkg returned an error code (1)” issue. Partial packages are remnants of incomplete installations or updates, which can cause conflicts and errors in your package management system. 

The autoclean command is used to remove partially downloaded package files. These files are stored in the /var/cache/apt/archives directory and can accumulate over time, potentially causing conflicts or consuming unnecessary disk space. Here’s how you can do it:

  1. Start by opening your terminal application. 
  2. Execute the following command to remove the partial packages:
sudo apt-get autoclean

This command cleans up the local repository of retrieved package files, removing any files that can no longer be downloaded and are largely useless.

removing unnecessary files and packages
  1. You will be prompted to enter your user password to proceed with the operation. Type your password and press Enter.

The command will run, and you will see a list of packages being removed if there are any.

entering password to start cleaning

4 Best Practices to Avoid the “sub-process /usr/bin/dpkg returned an error code (1)”

To avoid encountering the “sub-process /usr/bin/dpkg returned an error code (1)” message in the future, here are some best practices to follow:

1. Keep Your System Updated Regularly

Regularly updating your system ensures that all packages and dependencies are current and compatible.

  • Update Your Package List: Before installing or updating software, always refresh your package list to ensure you have the latest information.
  • Upgrade Packages: Regularly upgrade your installed packages to their latest versions to avoid compatibility issues.

2. Use Reliable Repositories

Using official and reliable repositories minimizes the risk of installing corrupt or incompatible packages.

  • Add Repositories Carefully: Only add trusted repositories to your system. Ensure they are well-known and reputable sources.
  • Remove Unused Repositories: Periodically review and remove any repositories that you no longer need or trust. This helps prevent conflicts and potential errors.

3. Regularly Clean Up Your System

Cleaning up your system helps to remove unnecessary files and packages that can cause conflicts.

  • Autoremove Unnecessary Packages: Remove packages that are no longer needed. This helps to keep your system clean and efficient.
  • Autoclean Partial Packages: Clear out partially downloaded package files to free up space and prevent potential issues.

4. Backup Your System Before Major Changes

Backing up your system allows you to restore it to a working state if something goes wrong.

  • Test Your Backups: Periodically test your backups to ensure they can be restored successfully. This gives you confidence that your data is safe and recoverable.
  • Create a Backup: Use backup tools to regularly back up your important data and system configuration. This ensures you can recover from any major issues that may arise.

    Wrap-Up

    In this article, I explored methods to fix the “sub-process /usr/bin/dpkg returned an error code (1)” error. These methods include fixing broken dependencies, reinstalling problematic packages, checking and fixing permission issues, and repairing the package database.

    If you found this article helpful, you might also be interested in:

    Frequently Asked Questions

    What are the common causes of the “sub-process /usr/bin/dpkg returned an error code (1)” message?

    The “sub-process /usr/bin/dpkg returned an error code (1)” message has several common causes, such as package dependency issues and conflicts, corrupted package databases, and permission issues. Conflicting dependencies can occur when trying to install multiple packages, while corrupted package databases can happen if the package manager is already running during an installation or upgrade. Permission issues can result from insufficient privileges when attempting to install or upgrade packages as a regular user instead of the root user.

    How can I view the list of packages installed on my Linux machine?

    You can use the apt list --installed command to view the list of packages installed on your Linux machine. This command will display a list of all packages that are currently installed on your system, including their version numbers and other relevant details. This can be a useful way to get an overview of the packages installed on your system and ensure that you have the necessary dependencies for your applications.

    Can I use a graphical package manager to fix this error?

    Yes, many Linux distributions include graphical package managers that you can use to fix this error. However, the Linux command prompt methods outlined in this article are typically faster and more effective to resolve this error.

    How can I search for a package using aptitude on my Linux machine?

    To search for a package using aptitude on your Linux machine, you can use the apt search command followed by a keyword related to the package name. For example, if you want to search for a Python3-related package, type apt search python3 in the Terminal. This will display a list of packages that match your search criteria, including their version numbers and other relevant details.

    How do I check for package dependency issues in Linux?

    You can check for package dependency issues in Linux by using the command sudo apt-get check. This command will check for any missing dependencies or conflicts with installed packages on your Linux system. Then, you can apply the solutions based on the root cause of the problem.

    How do I avoid permission issues when installing or upgrading packages in Linux?

    You can avoid permission issues when installing or upgrading packages in Linux by using the root user account or using the sudo command to elevate your privileges. It’s important to exercise caution when using elevated privileges to avoid accidentally modifying critical system files.

    Ojash

    Author

    Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.

    Akshat

    Reviewer

    Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

    Share this article
    Shareable URL
    Prev Post

    How to Fix the “Transport Endpoint is Not Connected” Error [5 Best Ways]

    Next Post

    [7 Proven Fixes] “gpg: no valid OpenPGP data found”

    Read next