How do I restore the sources.list file?
You can boot into a Live CD (a virtual machine will suffice) and copy /etc/apt/sources.list
from it. Alternatively, have a Live CD image ready and follow these instructions:
Mount the CD. If you've an
.iso
file, mount it using:sudo mount -o loop ubuntu-11.04-desktop-amd64.iso /media/cdrom
Mount the filesystem file from the CD:
sudo mount -o loop /media/cdrom/casper/filesystem.squashfs /mnt
Copy the sources.list file over:
sudo cp {/mnt,}/etc/apt/sources.list
Change the file permissions if necessary:
sudo chmod 644 /etc/apt/sources.list
From my Ubuntu 11.04 Live CD:
deb http://archive.ubuntu.com/ubuntu natty main restricted
deb-src http://archive.ubuntu.com/ubuntu natty main restricted
deb http://security.ubuntu.com/ubuntu natty-security main restricted
deb-src http://security.ubuntu.com/ubuntu natty-security main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu natty-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu natty-updates main restricted
## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
# deb http://archive.ubuntu.com/ubuntu natty universe
# deb-src http://archive.ubuntu.com/ubuntu natty universe
# deb http://archive.ubuntu.com/ubuntu natty-updates universe
# deb-src http://archive.ubuntu.com/ubuntu natty-updates universe
# deb http://security.ubuntu.com/ubuntu natty-security universe
# deb-src http://security.ubuntu.com/ubuntu natty-security universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb http://archive.ubuntu.com/ubuntu natty multiverse
# deb-src http://archive.ubuntu.com/ubuntu natty multiverse
# deb http://archive.ubuntu.com/ubuntu natty-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu natty-updates multiverse
# deb http://security.ubuntu.com/ubuntu natty-security multiverse
# deb-src http://security.ubuntu.com/ubuntu natty-security multiverse
For the best download speed, you need to re-select a mirror near you:
- Open the Ubuntu Software Center
- Open Edit -> Software Sources...
- Click the select box next to Download from:
- Select a server at your choice
You might want to enable some repositories as well, like Community-maintained Open Source software (universe) and Software restricted by copyright and legal issues (multiverse)
For 16.04
Here is a list you can use for /etc/apt/sources.list
Just run the following command:
sudo nano /etc/apt/sources.list
and then copy and paste the following contents into the file (these should be the only lines in the file!):
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
Press CTRL + o and then press ENTER to save the file. Press CTRL + x to exit nano
.
In case you are not on Ubuntu server i.e. with no GUI. You can follow the following steps:-
- Go to Software and updates.
- Select Ubuntu Software.
- Select the sources you want to have.
- Click on Close. It will ask you for reloading and updating cache.
- Click Reload.
Wait and relax; It will automatically create the sources.list file for you.