Ubuntu – sudo apt-get update failing – “could not open” list file due to “permission denied”


For the last week or more, running sudo apt-get update culminates in error:

Reading package lists... Done
E: Failed to fetch http://au.archive.ubuntu.com/ubuntu/dists/xenial/main/dep11/Components-amd64.yml  
Could not open file /var/lib/apt/lists/partial/au.archive.ubuntu.com_ubuntu_dists_xenial_main_dep11_Components-amd64.yml.gz - open (13: Permission denied) [IP: 80]
E: Failed to fetch http://au.archive.ubuntu.com/ubuntu/dists/xenial-backports/main/dep11/icons-64x64.tar  Could not open file /var/lib/apt/lists/partial/au.archive.ubuntu.com_ubuntu_dists_xenial-backports_main_dep11_icons-64x64.tar.gz - open (13: Permission denied) [IP: 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

Entering either of the 2 specified urls into a browser address bar results in a 'File not found' (404) error – but if I append .gz to both addresses, then the respective files can be downloaded.

However, having downloaded the 2 files, I then don't know how (or if) I can utilize them.

Seeking advice on how best to proceed.

Best Answer

  • The contents of that directory are partially downloaded lists (perhaps APT was interrupted?) which can be safely removed.

    Start a root shell, being aware that you now have permission to do all kinds of damage to your system, so be careful (we need to do this because sudo rm errors out)

    sudo -i

    Remove the contents of the directory (type carefully) and exit the root shell:

    rm /var/lib/apt/lists/partial/*

    Then run an APT update to regenerate the package lists and check the problem is gone:

    sudo apt update
  • Related Question