There are now errors when updating and I cannot install most software due to a corrupted
/etc/apt/sources.list
file. Is there a copy I can download to replace it?
The file would be for Ubuntu 12.04 (Final Beta) in the United States.
There are now errors when updating and I cannot install most software due to a corrupted
/etc/apt/sources.list
file. Is there a copy I can download to replace it?
The file would be for Ubuntu 12.04 (Final Beta) in the United States.
You can use this trick. Open a terminal ( Pressing Ctrl+Alt+T ) and do these
Move the corrupted one to the safe place
sudo mv /etc/apt/sources.list ~/
and recreate it
sudo touch /etc/apt/sources.list
Open Software & Updates
software-properties-gtk
This will open software-properties-gtk with no repository selected.
Then, change the server to Main server or to any other server of your choice. You must enable some repositories from the new window in order to create a new sources.list file in /etc/apt/.
Updated with inline content
In Ubuntu 24.04 and later Ubuntu software sources have been moved to /etc/apt/sources.list.d/ubuntu.sources. As a result the command cat /etc/apt/sources.list returns # Ubuntu sources have moved to /etc/apt/sources.list.d/ubuntu.sources in Ubuntu 24.04 and later.
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
This is the sources.list file for 12.04 Precise Pangolin.
###### Ubuntu Main Repos
deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
Ubuntu Update Repos
deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
Ubuntu Partner Repo
deb http://archive.canonical.com/ubuntu precise partner
deb-src http://archive.canonical.com/ubuntu precise partner
Ubuntu Extras Repo
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
If you're using another release, you need to replace the precise word with your Ubuntu release name. You can see which name you should use with this command:
lsb_release -c -s
To replace the word, you can use this sed command (assuming you copied the sources content in /etc/apt/sources.list):
sudo sed -i "s/precise/$(lsb_release -c -s)/" /etc/apt/sources.list
Note 1: the word deb and deb-src refers to the repository format. deb is for binary packages and deb-src is for source packages.
Note 2: Using # at the start of the line makes that line a comment. apt will ignore it, so any repositories mentioned on that line will be disabled.
Note 3: There are repository lines which includes all four components: main, universe, restricted, multiverse. You can disable one or more of them by removing the word.
Note 4: You can find some explanation of the repositories in this my other answer
For releases prior to and including 18.04, you can use https://repogen.simplylinux.ch (currently, 20.04 and later are not supported by this tool).
Select your Country and Ubuntu Release.
For the default set of repositories, you need to enable these repositories.
If you want to install software from Canonical Partner Repositories (closed source software), enable the Ubuntu Partner Repositories (both of them).
Enable any 3rd party repository you wish to enable.
Now, click the Generate List button at the bottom of that page and you'll see your generated sources.list.
Run the following commands in a Terminal.
sudo mv /etc/apt/sources.list /etc/apt/sources.list.old
gksudo gedit /etc/apt/sources.list
Copy/paste all the text from the newly generated sources.list to this file. Save it and close Gedit.
Now, update apt.
sudo apt-get update
This will update your repository index with the current sources.list and then you can install any software using Software Center, Synaptic or apt-get.
By default there will be a backup for your sources.list file on the same directory itself.
sudo cp /etc/apt/sources.list.save /etc/apt/sources.list
Answer from similar question here: What is the correct output of cat /etc/apt/sources.list?
Here is a better way to get all the default repositories back.
Create a directory where we can run our commands:
sudo mkdir ~/answer
Download the sources.list for Ubuntu 20.04 focal.
cd ~/answer/
sudo wget https://gist.githubusercontent.com/ishad0w/788555191c7037e249a439542c53e170/raw/3822ba49241e6fd851ca1c1cbcc4d7e87382f484/sources.list
Change the sources.list to match your version:
sudo sed -i "s/focal/$(lsb_release -c -s)/" ~/answer/sources.list
Backup your current sources.list:
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
Replace the sources.list:
sudo mv ~/answer/sources.list /etc/apt/
Run apt update:
sudo apt update
By default, the directory which contains all the PPA files is empty. If after restoring the repositories, you're still facing errors then you need to remove all the PPA files too.
Move the directory containing the PPA files to the ~/answer directory:
sudo mv /etc/apt/sources.list.d/ ~/answer
Recreate the directory:
sudo mkdir /etc/apt/sources.list.d
Run apt update:
sudo apt update
Remove the ~/answer directory:
sudo rm -r ~/answer
If the gist file used in the wget command above gets removed in the future, then you can copy the contents from here:
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu focal partner
deb-src http://archive.canonical.com/ubuntu focal partner