I was running an upgrade with the apt-get command, and it was taking an exceptionally long time because half way through my ISP hit me in the face with their fair usage policy.

After sitting outside & watching the rain for awhile my electronics regained consciousness, so I went back to complete the upgrade and my terminal scolds me with

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

The last bit of legible info was all this:

Installing (ri/RDoc) documention for (stuff and such)
ERROR:  Could not find a valid gem 'watobo-' (>= 0) in any repository
rm: cannot remove `watobo-': No such file or directory

Setting up metasploit (4.3.0-bt1) ...
Upgrading Pre-Existing Installation...
/opt/metasploit/postgresql/scripts/ctl.sh : postgresql  (pid 1191) already running
prosvc is running
metasploit is running
[*] Attempting to update the Metasploit Framework...

So on it goes for miles, talking about gem caches, rubies, & stuff I wish I had. All up until:

A    lib/gemcache/ruby/1.9.1/gems/state_machine-1.1.2/gemfiles/active_record-2.1.2.gemfile.lock

...and there it has sat, all night. If I stop it, will I still get the dpkg error (on the off chance that I won't), or if so what do I need to to resume using apt-get commands and its Super Cow Powers?


3 Answers 3

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

This error is actually telling you exactly what is wrong: dpkg was interrupted as a result the package was not configured correctly.

Run the command it tells you to sudo dpkg --configure -a and it should be able to correct itself.

If it doesn't try running sudo apt-get install -f (to fix broken packages) and then try running sudo dpkg --configure -a again.

Just make sure you have internet access available so that you can download any dependencies.

These instructions may not work if by upgrade you meant apt-get dist-upgrade if you were trying to do a distribution upgrade (e. g. 11.10 → 12.04) then you will need to edit your question to reflect that.

  • i have done the same but it did not worked check this one askubuntu.com/questions/469553/… May 20, 2014 at 14:16
  • running the dpkg command fixed the issue for me. i think there was some issue with rolling back from the 4.8 kernel to 4.4, there was a whole run of version sanity checks in the middle of configuration.
    – mendota
    Sep 1, 2017 at 0:14
  • 3
    running "apt-get install -f" also gives me the "dpkg was interrupted" message...
    – fei0x
    Aug 31, 2020 at 17:21
  • 1
    For me this results in the package that broke in the first place, attempting to install and thus causing the OS to hang. Nov 1, 2020 at 21:12
  • Nice. Worked for me somehow.
    – saumilsdk
    May 16, 2022 at 6:41

I tried the solution of @TrailRider and didn't work for me. I solve it doing the following:

  1. Delete the updates with:

    cd /var/lib/dpkg/updates
    sudo rm *
  2. Tried to update and upgrade:

    sudo apt update
    sudo apt upgrade
  3. I couldn't, it says that:

    E: Could not get lock /var/lib/dpkg/lock

    This means that some program is updating the system or installing a new software.

  4. IMPORTANT: Check if some other process is locking dpkg files instead of deleting them immediately. Because if that is the case, you should wait for them to finish.

  5. Checking if some programs is locking dpkg files:

    ps aux | grep -i apt

    If you have only one output, something that finishes like:

    S+   19:16   0:00 grep --color=auto -i apt

    you are lucky. You could delete the dpkg lock files which you can double-check manually one by one with:

    sudo lsof /var/lib/dpkg/lock
    sudo lsof /var/lib/apt/lists/lock
    sudo lsof /var/cache/apt/archives/lock

    To delete them use:

    sudo rm /var/lib/apt/lists/lock
    sudo rm /var/cache/apt/archives/lock
    sudo rm /var/lib/dpkg/lock
  6. Try again:

    sudo dpkg --configure -a

    It should work.

  7. You should try to recover whatever you were installing at that moment with:

    sudo apt update
    sudo apt upgrade

    This should resume the process and keep everything stable.

That is how I fix it.

NOTE: I recommend you whatever you try to keep of track/log of what commands are you applying, this precaution will help other to help you if something goes wrong.

  • Please consider a title OP from me, cause you saved my laptop stuck after upgrade 20.04.1 stuck for a week.
    – Sayan Dey
    Oct 20, 2020 at 7:10
  • 1
    Thank you so so so so much!!!..it worked....I had to kill the process running in the background first which I was able to see using your suggestion ps aux | grep -i apt ..it showed me two process so I killed the first one and kept S+ 19:16 0:00 grep --color=auto -i apt , then I followed everything as you said
    – coderina
    Jul 29, 2021 at 6:06

Boot to the GRUB menu, choose Advanced options for Ubuntu, and select the second option (the option that has (recovery mode) at the end). Then run sudo dpkg --configure -a to correct the problem. The following detailed instructions describe how to do this step-by-step.

Boot into recovery mode

Immediately after the motherboard / computer manufacturer logo splash screen appears when the computer is booting, with BIOS, quickly press and hold the Shift key, which will bring up a GNU GRUB menu screen. With UEFI press (perhaps several times) the Esc key to get to the GNU GRUB menu screen. Sometimes the manufacturer's splash screen is a part of the Windows bootloader, so when you power up the machine it goes straight to the GNU GRUB menu screen, and then pressing Shift is unnecessary.

The timing when to press the left Shift key can be tricky, so sometimes if you miss it you need to try it again. If that doesn't work try the answers to I can't get the GRUB menu to show up during boot. Then runsudo dpkg --configure -a' to correct the problem

You will see a GNU GRUB menu screen that looks like this. Select Advanced options for Ubuntu and press Enter.

enter image description here

A new purple screen will appear showing a list of kernels, which includes options of booting the kernels normally or in recovery mode.

enter image description here

Press the down arrow key until you select the 2nd entry from the top (the one with the recovery mode in the description) and then press Enter twice.

Now you should see this recovery menu:

recovery menu

Using the arrow keys scroll down to network (the third entry from the bottom in the Recovery Menu) and then press Enter.

Using the arrow keys scroll down to root (the second entry from the bottom in the Recovery Menu) and then press Enter.

You should now see a root prompt and you can run commands from it.

Run 'sudo dpkg --configure -a' to correct the problem

Run the following commands.

sudo mount -o remount,rw /
fsck -f /
sudo dpkg --configure -a
sudo apt-get install -f

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .