Ubuntu stopped installing updates, and now every install ends with a message about dpkg being interrupted or broken packages. The fix is usually two commands, run in order, and it takes a few minutes. This guide walks through them in the safe order and explains what each one does in plain language.
If you want the short version, open a terminal with Ctrl+Alt+T and run these two commands, one at a time, waiting for each to finish:
sudo dpkg --configure -a
sudo apt --fix-broken install
The first command finishes the setup work an earlier install left half done. The second fetches and installs any missing pieces those packages need. If both finish without an error, run sudo apt update and then sudo apt upgrade to complete the update you started. The rest of this guide explains when to use each command and how to check that the system is actually fixed.
This guide was written for Ubuntu 26.04.1 LTS, the current long term support release, and the same commands work on Ubuntu 24.04 LTS, which is still supported until May 2029. The steps apply to the desktop edition and to Ubuntu Server.
What each command actually does
Ubuntu installs software in two layers. Apt is the friendly front end you normally talk to: it downloads packages and works out which other packages they need. Dpkg is the lower level tool that does the actual work: it unpacks the files, then runs each package’s setup script. When an install is interrupted between those two steps, a package sits on your system unpacked but not configured, and apt refuses to do anything else until that is sorted out.
That is why the order matters. The configure command finishes the low level work first, and only then can apt repair the dependencies. Running the repair command first just repeats the same error.
| Command | What it does, in plain language | When to run it |
|---|---|---|
| sudo dpkg –configure -a | Finishes setting up every package that was unpacked but never configured | First, whenever apt says dpkg was interrupted |
| sudo apt –fix-broken install | Downloads and installs the missing pieces that installed packages need | Second, after the configure step, or when apt reports unmet dependencies |
| sudo apt update | Downloads fresh lists of available packages from your software sources | After a repair, before installing or upgrading anything |
| sudo apt upgrade | Installs newer versions of the packages already on your system | Last, once the repair is done |
| sudo dpkg –audit | Lists packages stuck halfway through installation, or prints nothing when all is well | At the end, to confirm the repair worked |
Every command here starts with sudo, which runs it with administrator rights. Ubuntu asks for your password the first time you use sudo in a terminal session. Type it and press Enter: nothing appears on screen while you type, which is normal.
What your error message means
Three different problems hide behind the phrase broken packages, and each one has a different fix. Reading the message before running commands saves time, because the lock error is not a broken package at all.

“dpkg was interrupted”
This is the most common case. An install or upgrade stopped before it finished, so some packages were unpacked but never configured. The usual causes are a power cut, a laptop battery running out, a closed terminal window, a reboot during an update, or pressing Ctrl+C because the upgrade looked stuck. Apt will not install, remove, or upgrade anything until the unfinished configuration is completed, and the message itself tells you the fix: run sudo dpkg –configure -a.
Unmet dependencies, or “you have held broken packages”
This means a package is installed without the other packages it needs to run. It often happens after installing a downloaded .deb file by hand, because dpkg on its own does not fetch dependencies, or after adding a software source that offers clashing versions of the same package. The fix is sudo apt –fix-broken install, which works out the missing pieces and installs them.
“Could not get lock”
This one means another program is already using the package system: the Software Center, the update manager, Synaptic, or Ubuntu’s automatic background updates. Nothing is broken, and no repair command will help until that other program finishes. Wait for it, then try your command again. The lock section below explains how to check what is running and when a lock file is safe to clear.
| What you see | What it means | Start here |
|---|---|---|
| dpkg was interrupted, you must manually run dpkg –configure -a | An earlier install stopped halfway, leaving packages unconfigured | Step 1, the configure command |
| The following packages have unmet dependencies | A package is missing pieces it needs to run | Step 2, the fix-broken command |
| Could not get lock /var/lib/dpkg/lock-frontend | Another update or installer is already running | Wait, then check the lock section |
| Sub-process /usr/bin/dpkg returned an error code (1) | A package setup script failed; the real reason is printed above this line | Read the lines above it, then the section on repeated failures |
Before you start: make sure nothing else is updating
Close the Software Center, the update manager, and Synaptic if any of them are open, because only one program may change packages at a time. Ubuntu also runs automatic background updates, usually shortly after the computer starts.
Before running any repair, check what is actually running. Open a terminal with Ctrl+Alt+T and run:
ps aux | grep -E 'apt|dpkg|unattended'
This lists running processes whose names mention apt, dpkg, or unattended updates. If you see lines for apt-get, dpkg, or unattended-upgrades, something is still working, and the right move is to wait. Automatic updates usually finish within a few minutes.
Step 1: Finish the interrupted setup
With nothing else updating, run the command the error message itself suggests:
sudo dpkg --configure -a
The –configure option tells dpkg to run the setup step for a package that has been unpacked but not yet configured, and -a applies it to all such packages at once. Dpkg works through each unfinished package in turn. On a system with a large interrupted upgrade, this can take several minutes, so let it finish and do not close the terminal or press Ctrl+C while it runs.

If the command prints nothing and returns to the prompt, there was nothing left to configure, which is good news. If it asks you a question about a configuration file, read it and answer it: it is part of finishing the setup. If it ends with an error instead, note the package name in the last few lines and keep going to the section on repeated failures below.
Step 2: Repair the broken dependencies
Once the configure step has finished, run apt’s repair command:
sudo apt --fix-broken install
The –fix-broken option, which you may also see written as -f, tells apt to correct a system with broken dependencies in place. Apt works out which pieces are missing, downloads them, and installs them so the half-finished packages work again.
Read what apt plans to do before you confirm it. It prints a list of the packages it will install, and sometimes it offers to remove a package that cannot be fixed any other way. If the removal list contains software you use every day, press N to stop, and fix that package first using the steps in the repeated failures section.
Step 3: Refresh the lists and finish the update
With the repair done, refresh the package lists and complete the update that was interrupted in the first place:
sudo apt update
sudo apt upgrade
The update command downloads fresh lists of available packages from your software sources. It installs nothing itself: it only makes sure apt knows what is available. The upgrade command then installs the newer versions of the packages already on your system.
Now confirm the system is actually clean. Run the audit command:
sudo dpkg --audit
This checks the package database for packages installed only partly, or with missing or wrong control data. No output means dpkg found nothing half installed, which is the result you want. A second check, sudo apt-get check, reports any broken dependencies that remain.
What to do about a lock error
A lock error looks alarming, but it is usually the easiest of the three problems. The package system uses lock files so that only one program changes packages at a time. When apt or dpkg is running, it holds the lock, and any other package tool that starts up reports that it could not get the lock and stops.

The first step is always to find out what holds the lock. The process check from the start of this guide, ps aux with grep for apt, dpkg, or unattended, shows whether an update is still running. You can also ask directly which process holds the dpkg lock:
sudo fuser -v /var/lib/dpkg/lock
If either check shows a running process, wait for it. Automatic updates usually finish within a few minutes of starting. Only when you have checked and no apt, dpkg, or update process is running anywhere on the system is it safe to clear a stale lock. A lock left behind by a crashed update is the one case where removing the files is the right move, and even then only these four files:
sudo rm /var/lib/dpkg/lock /var/lib/dpkg/lock-frontend /var/lib/apt/lists/lock /var/cache/apt/archives/lock
Never delete anything else under /var/lib/dpkg. That folder holds the database of every package on your system, and removing the wrong file there turns a small problem into a broken package system. Deleting a lock file while a process still holds it is just as risky: it lets two programs write the package database at the same time, which is how real corruption happens. After clearing a genuinely stale lock, run sudo dpkg –configure -a again, then continue with Step 2.
If dpkg –configure -a keeps failing
Sometimes the configure command itself fails, and apt ends with the generic line “Sub-process /usr/bin/dpkg returned an error code (1)”. That last line only says dpkg failed: it never says why. The reason is printed above it, usually naming the package and the step that failed. Read those lines first, because they decide the fix. The dpkg manual documents the configure step used in this guide.
Free some disk space
A full disk is one of the most common reasons a configure step fails partway through, often reported as “No space left on device” in the lines above the final error. Check how full your disks are:
df -h
Look at the Use% column for the line mounted on / , the root filesystem. If it is at or near 100%, free space before trying the repair again. A safe first step is clearing the cache of downloaded package files, which apt can download again later if needed:
sudo apt clean
Empty the trash, remove large files you no longer need, and uninstall software you do not use. Then run the configure command again.
Deal with a held package
A package on hold stays at its current version, and apt will not upgrade it or install anything that conflicts with it. A hold you set yourself and forgot about can block an upgrade and produce dependency errors that look like breakage. List held packages with:
apt-mark showhold
If a package on the list is one you deliberately held back, leave the hold alone and work around it. If the hold is yours and no longer needed, release that one package with sudo apt-mark unhold package-name, using the real package name, and then run the repair sequence again from Step 1.
Remove or reinstall the one broken package
When the error always names the same package, the problem is usually with that package rather than the system as a whole. Try reinstalling it first, which replaces its files while keeping your settings:
sudo apt install --reinstall package-name
Replace package-name with the real name from the error message. If reinstalling fails the same way, and you do not need the package, remove it completely with sudo apt purge package-name, which removes the package and its configuration files, then run sudo apt –fix-broken install once more.
When nothing else works: reinstall Ubuntu
A fresh install is the last resort, and it is rarely needed for broken packages alone. Consider it only when several packages are stuck, the package database itself reports damage, and the steps above have all failed. Back up your files first, because reinstalling wipes the system.
From there the path is the same as any fresh install: create a bootable Ubuntu USB on Windows with the installer file, then install Ubuntu alongside or over the broken system. The install guide covers the installation itself, including keeping Windows next to Ubuntu if you dual boot. A clean install takes under an hour in most cases.
How to stop this happening again
Most interrupted installs come from a small set of habits, and each one is easy to change. Let updates finish before you close the laptop lid or shut the computer down, and keep the laptop plugged into power during a large upgrade. Run only one installer or updater at a time, and close the Software Center before using apt in the terminal, so the two never fight over the lock.
Keep a little free disk space as well, since upgrades need room to download and unpack before they install. Finally, when you install a downloaded .deb file, use apt instead of dpkg on its own, because apt fetches the dependencies while dpkg does not:
sudo apt install ./package-name.deb
Run that command from the folder holding the file. Apt installs the package and pulls in anything it needs in the same step, which avoids the unmet dependency errors that a bare dpkg install often leaves behind.
Quick answers to common questions
Running sudo dpkg –configure -a twice does no harm. It only configures packages that are still unfinished, so a second run on a healthy system prints nothing and finishes at once. The command does not touch packages that are already installed and configured correctly.
Broken packages look alarming, but most of the time the system is one interrupted step away from working again. Finish the configuration, repair the dependencies, and check the result with the audit command.
- How to Fix Broken Packages and “dpkg Was Interrupted” on Ubuntu [Fix] - November 30, 2026
- How to Create a Bootable Ubuntu USB on Windows (Step-by-Step Guide) - November 29, 2026
- How to Run AI Models Offline With LM Studio (Step-by-Step Guide) - November 28, 2026
