88

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, 2020 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, 2020 at 19:43

8 Answers 8

112

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.

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

     sudo dpkg --configure -a
    
  2. Get your system up-to-date:

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

     sudo dpkg-reconfigure -plow unattended-upgrades
    

    Select the package unattended-upgrades again.

0
13

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 minutes.

In my case, it gave the following 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 its own (took like 5 minutes).

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 a little while.

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.

In either case, delete lock files only as last resort.

2
  • 1
    I followed you wise advise with the same message and waited 5 minutes. It worked.
    – Oulala
    Oct 15, 2020 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, 2020 at 2:58
6

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, 2021 at 7:48
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, 2019 at 17:33
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.

2
  • 1
    Bad advice. If its running its doing something important. Use systemctl to stop it properly.
    – Shayne
    Nov 17, 2021 at 23:26
  • The system is telling your "wait, this lock file means that we cannot proceed because we can corrupt the system". When you use kill -9 you are taking a shotgun a shooting the process. It does not have to finish nicely, so you are putting yourself in a situation where you can corrupt the system. Don't do this unless you fully understand what is going on.
    – Tk421
    Jan 16, 2022 at 23:57
1

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.

2
  • Re "The wait is long": Can you be more specific? Is it 10 minutes? 1 hour? 4 hours? Oct 31, 2021 at 21:34
  • 1
    Sorry, I do not remember exactly how long I had to wait. It was long enough to make me start searching for why I was stuck, so I would say at least 30 mins or more. Nov 1, 2021 at 16:32
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.

You must log in to answer this question.

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