How to Fix 'dpkg was interrupted' and Restore Your Ubuntu/Debian System

beginner🐧 Linux2026-07-18| Ubuntu (all versions), Debian, Linux Mint, Kali Linux, and other Debian-based distributions.

Error Message

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
#dpkg#ubuntu#debian#apt#linux-tips

What happened?Seeing the dpkg was interrupted error usually means your Linux system stopped mid-task. This often happens if your laptop battery dies during a 500MB update or if you accidentally close the terminal while a new kernel is installing. Because the process stopped abruptly, the package manager 'locks' itself to prevent your system files from getting corrupted.

You will know you are stuck when every apt command returns this specific block of text:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

Step 1: The Built-in FixThe error message actually tells you exactly how to start. The --configure -a flag tells dpkg to look for packages that were unpacked but never finished the setup phase. It then tries to complete those pending configurations.

Open your terminal and run this command:

sudo dpkg --configure -a

For minor interruptions, this takes about 30 seconds. The command will list the packages it is configuring. If it finishes without an error message, your system is likely back to normal. If it fails, move to the next step.

Step 2: Clearing Stubborn Lock FilesSometimes the command above fails with a new error: Could not get lock /var/lib/dpkg/lock-frontend. This usually means a background process—like the automatic software updater—is already trying to fix the system. It could also mean a 'stale' lock file was left behind after a crash.

First, check if any apt processes are currently active:

ps aux | grep -i apt

Wait a minute or two if you see an active unattended-upgrades process. If no processes are running but you still see the lock error, you must delete the lock files manually to let the system move forward. Run these commands one by one:

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

Once those files are gone, try the configuration command again:

sudo dpkg --configure -a

Step 3: Repairing Broken DependenciesEven after configuring packages, your system might have 'broken' links where one piece of software needs a library that didn't finish downloading. You can tell the Advanced Package Tool (APT) to scan for and repair these missing pieces.

Run the fix-broken command:

sudo apt install -f

This command is a lifesaver. It identifies partially installed packages and either completes them or removes them to restore stability. It might ask to download a few extra megabytes of data to finish the job.

Step 4: Refreshing the SystemAfter repairing the database, sync your local package list with the remote servers. This ensures your system knows exactly what versions are available and clears out any lingering confusion.

sudo apt update
sudo apt upgrade

Advanced Fix: Cleaning the CacheIf you still encounter errors, a downloaded .deb file might be corrupted. You can wipe the local cache to force the system to download fresh, clean copies of the software.

sudo apt clean
sudo apt autoclean

This clears out the /var/cache/apt/archives/ folder. It won't uninstall your apps; it just removes the temporary setup files.

Verification: Is it Fixed?Double-check your work by running a simple update. If the following command finishes without mentioning 'dpkg' or 'locks,' you have successfully recovered your system:

sudo apt update

You should see a clean output ending with a message like "All packages are up to date."

How to Prevent Future CrashesAvoid these common pitfalls to keep your package manager healthy:

  • Watch the prompt: Never close your terminal window until the command prompt (like user@linux:~$) reappears.- Plug in your power: Always connect your laptop to a charger before running a large dist-upgrade.- Be patient: If a package seems stuck at 99%, give it at least 5 minutes. Some scripts take time to run hardware triggers. If you must stop a process, use Ctrl+C instead of force-closing the window.

Related Error Notes