14

I accidentally removed my /etc/apt/sources.list file. Is it hosted by Canonical somewhere so I can re-add it to the system? It's a bit of an emergency, so I hope someone can provide a quick answer.

Lekensteyn
  • 174,277
Oxwivi
  • 17,849

4 Answers4

10

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:

  1. Mount the CD. If you've an .iso file, mount it using:

    sudo mount -o loop ubuntu-11.04-desktop-amd64.iso /media/cdrom
    
  2. Mount the filesystem file from the CD:

    sudo mount -o loop /media/cdrom/casper/filesystem.squashfs /mnt
    
  3. Copy the sources.list file over:

    sudo cp {/mnt,}/etc/apt/sources.list
    
  4. 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:

  1. Open the Ubuntu Software Center
  2. Open Edit -> Software Sources...
  3. Click the select box next to Download from:
  4. 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)

Lekensteyn
  • 174,277
3

In case you are not on Ubuntu server i.e. with no GUI. You can follow the following steps:-

  1. Go to Software and updates.
  2. Select Ubuntu Software.
  3. Select the sources you want to have.
  4. Click on Close. It will ask you for reloading and updating cache.
  5. Click Reload.

Wait and relax; It will automatically create the sources.list file for you.

earthmeLon
  • 11,247
ARP
  • 56
2

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.

mchid
  • 43,546
  • 8
  • 97
  • 150
  • Is it the default configuration? According to the top answer, the pagkages from multiverse are not officially supported. – A.L Nov 29 '16 at 20:10
  • @A.L Like lots of open source stuff, packages from Universe and Multiverse are maintained by the Ubuntu community and Debian. Although not "officially supported" by Canonical, that is to say, Multiverse and Universe are not maintained by Canonical. Multiverse is officially Ubuntu, just not Canonical. However, Multiverse and Universe are by no means unsupported repositories and Multiverse is by no means an unsupported PPA. Unlike Universe, Multiverse contains a lot of closed-source, licensed software, and some open-source stuff with licensing restrictions. – mchid Nov 30 '16 at 11:51
  • 1
    @A.L Also, it depends on the default configuration. When installing Ubuntu, it usually asks if you want to install extra codecs for mp3 support and a lot of people select this option. This software depends on the Multiverse repo and so this should be enabled in case of any security updates. You can always delete the word multiverse from this list if you don't want it, however, hardware specific firmware such as nvidia drivers, some printer firmware, mp3 compatibility, audio and video codecs, wine, all the restricted extras, sun-javadb, many fonts, virtualbox, many fonts, some broadcom – mchid Nov 30 '16 at 11:59
  • @A.L . . . broadcom wireless firmware, alsa-firmware-loaders, p7zip-rar, matlab-support etc. Also, they do receive security updates but it is up to whoever publishes the code to provide those security updates and the updates are not provided by Canonical. If you have any software from this repository installed (if you have mp3 capability even) you should not disable this repository or you may miss a security update and your system would then possibly be vulnerable. As I mentioned, however, you can omit the word multiverse from the file to disable it or comment it out like #multiverse – mchid Nov 30 '16 at 12:19
  • 1
    @A.L You may find this article interesting http://www.howtogeek.com/194247/whats-the-difference-between-main-restricted-universe-and-multiverse-on-ubuntu/ Also, this article explains the restricted licences in more detail: http://www.howtogeek.com/144083/why-ubuntu-doesnt-come-with-support-for-mp3s-flash-and-other-multimedia-formats/ – mchid Nov 30 '16 at 12:22
1

I used the nifty sources.list generator over at http://repogen.simplylinux.ch/ - this may not be appropriate for everyone, but it works quickly and simply if you know which options you want to select.

sage
  • 677