54

I'm unable to update my system having two installations of Ubuntu: One is version 16.04 and the other version is 17.04. In both, I'm getting the same error.

For ex., in Ubuntu 16.04, I run software updater and get the result as shown below.

checking for updates

I did wait for some time but the updater didn't proceed ahead.

Then I pressed the Stop button and it took me to the below pop-up.

data to be downloaded

Then I pressed the button Install now and it took me to the next pop-up as shown below.

installing upgrades progress bar

I waited here for some time but it got stuck there.

I'm unable to update in either installation.

What is the solution as I can't do any update?

(Also would like the viewer to see if unauthorized tampering, remotely or otherwise, can result in this error. If so, how to solve the issue?)

If I fail to update, I may be compelled to take the trouble of reinstalling both the installations from scratch which I would like to avoid.

Referring to the 3rd picture above that mentioned "installing updates": It did proceed ahead and updated completely. But after rebooting and running again the software updater, I came across a new issue. Now on running the software updater, it messages check your Internet connection. I've posted the question here.

2
  • askubuntu.com/questions/934807/unattended-upgrades-status shows how you might get some idea of what unattended-upgr is doing, and why it might be stuck.
    – mwfearnley
    Mar 15 '20 at 18:43
  • an old thread... but fyi i had the same problem - it seems it was in the middle of an upgrade. thus... the first thing to try is to just restart and maybe the logjam will clear itself.
    – user407201
    Apr 18 '20 at 19:43
73

I would first try a softer way.

  1. Stop the automatic updater.

    sudo dpkg-reconfigure -plow unattended-upgrades
    

    At the first prompt, choose not to download and install updates.
    Make a reboot.

  2. Make sure any packages in an unclean state are installed correctly.

    sudo dpkg --configure -a
    
  3. Get your system up-top-date.

    sudo apt update && sudo apt -f install && sudo apt full-upgrade
    
  4. Turn the automatic updater back on, now that the blockage is cleared.

    sudo dpkg-reconfigure -plow unattended-upgrades
    

    Select the package unattended-upgrades again.

1
6

Do not jump to deleting lock files as soon as you see this issue. There might be some process actually updating packages. It might be worth waiting for a few mins.

For me it gave below error:

athakur:~$ sudo apt-get upgrade
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

I had logged in to my Ubuntu System after a long time and some internal process was updating something. It got resolved on it's own (took like 5 mins).

You can check this with commands like

  • sudo ps -eaf | grep -i apt
  • sudo lsof /var/lib/dpkg/lock-frontend

If you see a process like "apt.systemd.daily" running you can wait for some time. If not you can kill those processes and resume what you wanted.

  • sudo kill -9 PID

Replace PID with PIDs you get from the above command. Then you can run

sudo dpkg --configure -a

to let dpkg fix itself. Either case, delete lock files only as last resort.

2
  • I followed you wise advise with the same message and waited 5 minutes. It worked.
    – Oulala
    Oct 15 '20 at 4:06
  • 1
    I just had to ps -e, then located the unattended-upgr process and its PID, and then sudo kill -9 PID, this lead me the right direction, so thanks.
    – jackw11111
    Nov 19 '20 at 2:58
5

I simply copy-pasted a solution from another question on Ask Ubuntu, “Unable to lock the administration directory (/var/lib/dpkg/) is another process using it”. All the credit goes to zurdo.

This should be used as last resort. If you use this carelessly you can end up with a broken system. Please try the other answers before doing this.

You can delete the lock file with the following command:

sudo rm /var/lib/apt/lists/lock

You may also need to delete the lock file in the cache directory

sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

After this you should be able to do your updates!

1
  • 1
    There is a rather large note on this solution that bears repeating here: This should be used as last resort. If you use this carelessly you can end up with a broken system. Please try the other answers first before doing this Jul 16 '19 at 17:33
2

Here is my recommendation:

  • unattended upgrade service is running

    systemctl list-units --type=service | grep upgr
        unattended-upgrades.service                                                               
        loaded active running Unattended Upgrades Shutdown
    
  • stop the service (“stop”, not “disable”)

    sudo systemctl stop unattended-upgrades
    
  • proof, it's no longer running:

    systemctl list-units --type=service | grep upgr
    ( nothing )
    $>
    
  • do your upgrade thing

After reboot (or manually start again), the service will automatically start again. Thus no danger of leaving a permanent security issue. You can verify that by typing again:

systemctl list-units --type=service | grep upgr
    unattended-upgrades.service                                                               
    loaded active running Unattended Upgrades Shutdown
1
  • 1
    Thanks, this worked for me when running: systemctl stop unattended-upgrades Aug 5 at 7:48
1

I installed Ubuntu Mate 20.04 on my new RPi 4 B. Ran the updater from the welcome page and got the "waiting for unattended upgr" message. I pressed the stop button in the popup and another popup offered a partial upgrade. Trying that resulted in the "waiting for unattended upgr" message again. I shut down from the menu and tried to upgrade from the welcome page again and once again got the "waiting for unattended upgr" message. Once again I shut down from the menu and then turned off power to the RPi. After restart I ran the updater from the welcome page and it worked this time. Hope this helps someone.

1

Step 1: Find the process id [pid] of the offending process
sudo lsof /var/lib/dpkg/lock-frontend

Step 2: Terminate the process
sudo kill -9 [pid]

Note: Please do not attempt this without waiting 10-20 min first, you want to give the process time to complete it's task, if it doesn't complete after about 20 min, you can assume the process is stuck and can then be terminated.

0

As mentioned in the previous answers, very likely the daily upgrade task is ongoing. I understand that the question is how to not get the error, but in most cases you may want to wait (which is when I started searching for this issue and stumbled upon this discussion). The wait is long specially if you've just installed the distro using an old live CD/DVD because there would be a lot of upgrades pending. An indirect method to get an idea of the wait time would be to check the progress of the auto update by sudo apt update. At the very end of the output you'd see how many packages need updating (the actual list is generated by apt list --upgradable). The number of packages that can be upgraded would keep decreasing as the auto-updater works its charm.

0

Simply Restart your system and the unattended software update will automatically get closed. You can then easily update either using software update app or simply running "sudo apt update" in terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.