Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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)

share|improve this answer

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.

share|improve this answer
    
Just checked it out... really interesting. –  Scott Goodgame Apr 10 '13 at 18:57
    
In case anyone is coming here from standard Debian, debgen.simplylinux.ch is a handy sources.list generator for us. –  valerietheblonde Jul 28 at 14:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.