When you install offline, it can happen that a bunch of outdated repositories get added to your sources. Assuming you have connected via ethernet now, all you have to do is fix the sources. Remove the broken contents of the sources.list.d
directory, making a backup first (and typing carefully!)
cd /etc/apt
sudo cp sources.list.d sources-d-bak
sudo rm sources.list.d/*
Now try to update again. If you still have problems, you need to edit the sources.list
itself and comment out (by inserting a #
at the start of the line) the problematic entries
sudo cp sources.list sources-bak
sudoedit sources.list
Leave uncommented at least the lines that mention main and security updates repositories, and most likely you also want to keep universe/multiverse repositories. Comment out the deb-src
lines if you do not want to enable downloading source code. The things to keep look something like this (depending on your location):
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
Comment out any lines that mention sourceforge or other external repositories as the links are most likely outdated. Save and exit and you will be able to update.
Alternatively, @Anwar suggests, based on his own experience, that changing your mirror from the regional to the main Ubuntu mirror could solve the problem.
To do this, remove the region labels in the sources.list
, replacing, for example, this:
http://us.archive.ubuntu.com/ubuntu
with this
http://archive.ubuntu.com/ubuntu
Some suggestions to do this quickly: Make a backup copy as before, then use Vim or Vi: sudo vi /etc/apt/sources.list
and type (replace us.
with your region):
:%s/us.//gc
This deletes instances of us.
but is interactive so you can press y
to proceed or n
to skip and move to the next instance. (When that is done type :wq
to save and exit)
or if you prefer (back up first!):
sudo sed -i 's/\/us./\//g' /etc/apt/sources.list
This replaces all occurrences of /us.
with /
(matching an extra character just in case there is a us.
anywhere we don't want to delete)