Tuesday, October 22, 2019

How do I restore the sources.list file?





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.



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)


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...