7

I have Ubuntu 12.04. I need the correct output of cat /etc/apt/sources.list. I edited it because it wasn't working, but it has only made it worse. I need to know what the default sources.list contains in order to restore my modified sources.list file back to the default sources.list.

karel
  • 122,292
  • 133
  • 301
  • 332
jack
  • 89

2 Answers2

21

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

Ubuntu 24.04 uses a new format for managing sources. Sources are stored in separate files within the /etc/apt/sources.list.d/ directory, each named with a .list or .sources extension (example: ondrej-ubuntu-php-noble.sources). When you add a PPA source, it usually creates a new file within this directory specific to that PPA. The PPA information goes into this new file, not the existing ubuntu.sources file.


You can recreate a standard ubuntu.sources in Ubuntu 24.04 and later using a heredoc by running the following commands.

sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/backup.txt 
cat <<EOF | sudo tee /etc/apt/sources.list.d/ubuntu.sources
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main universe restricted multiverse
EOF
sudo apt update

You can recreate a standard sources.list in Ubuntu 22.04 using a heredoc by running the following commands.

sudo cp /etc/apt/sources.list /etc/apt/backup.txt 
cat <<EOF | sudo tee /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main universe restricted multiverse
EOF
sudo apt update

You can also write a new standard sources.list to a new backup file named BACKUP.txt in Ubuntu 22.04 without changing the existing /etc/apt/sources.list file using a heredoc like this.

cat <<EOF >> ~/Desktop/BACKUP.txt
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main universe restricted multiverse
EOF

Here is a simple example of a standard /etc/apt/sources.list file for Ubuntu 22.04:

deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu jammy-security main restricted universe multiverse

The partner repository has been empty since Ubuntu 20.10.

The easiest way to edit the sources.list file is from the terminal in nano editor using the following command:

sudo nano /etc/apt/sources.list  

The instructions for using nano are always displayed at the bottom of the page. Use the keyboard combination Ctrl + O and after that press Enter to save the file to its current location. Use the keyboard combination Ctrl + X to exit nano.

Make sure to run this command after changing sources.list to refresh the list of available software.

sudo apt update  

A standard sources.list file for Ubuntu 20.04 looks like this:

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu focal partner

A standard sources.list file for Ubuntu 18.04 looks like this:

deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu bionic partner

A standard sources.list file for Ubuntu 16.04 looks like this:

deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu xenial partner

A standard sources.list file for Ubuntu 14.04 looks like this:

deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu trusty partner

A standard sources.list file for Ubuntu 12.04 looks like this:

deb http://archive.ubuntu.com/ubuntu precise main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu precise-updates universe main multiverse restricted
deb http://archive.ubuntu.com/ubuntu precise-backports universe main multiverse restricted
deb http://archive.ubuntu.com/ubuntu precise-security universe main multiverse restricted
karel
  • 122,292
  • 133
  • 301
  • 332
3

I know it is quite late to answer this question but since (being a newbie), I spent more than 24 hours due to this issue, I found this link quite helpful. It contains all default content for the ubuntu files: https://repogen.simplylinux.ch/

Actually this site takes information from the user about their distro of linux and the names of files they want and then provides the default content of files as output which we can copy and use.

ARK
  • 139