Ubuntu linux sources list

Understanding sources.list in Ubuntu and Debian

Understanding the concept of sources.list in Ubuntu will help you understand and fix common update errors in Ubuntu.

I hope you are familiar with the concept of package managers and repositories. A repository is basically a web server that has packages (software). The package manager gets these packages from the repositories. How does the apt package manager know the address of the repositories? The answer is sources.list file.

What does sources.list do?

Default sources list file in Ubuntu

It’s basically a text file that contains the repository details. Each uncommented line represents a separate repository. The lines follow a specific format, though. It’s usually composed of this:

archive-type repository-url distribution component
deb http://archive.ubuntu.com/ubuntu impish main restricted

Archive type is deb here, meaning you’ll get precompiled .deb packages. Another archive type is deb-src which provides the actual source code but usually it is commented out (not used by the system) because a regular user doesn’t need the source code of an application. The deb file lets you install the package. Repository URL is http://archive.ubuntu.com/ubuntu. In fact, you can visit this URL and see various available folders (that contain the package details). Index of Ubuntu repositoryNext, the distribution is impish. On the actual repository, it is represented as dists. It’s because there are several categories of repositories like impish-security (for security packages), impish-backports (for backported packages) etc. This is why it’s not just the distribution name. So, you can go to this URL http://archive.ubuntu.com/ubuntu/dists/ and see that impish (codename for Ubuntu 21.10) is one of the available folders among many other choices here. Sources.list explanationThe component is one of the five types of default Ubuntu repositories. Understanding UbuntuYou can combine more than one (if available) in the same line, actually. Instead of writing two lines like this:

deb http://archive.ubuntu.com/ubuntu impish main deb http://archive.ubuntu.com/ubuntu impish restricted
deb http://archive.ubuntu.com/ubuntu impish main restricted

This means when you have a repository detail like “deb http://archive.ubuntu.com/ubuntu impish main” in the sources.list, it gets software packages details stored at http://archive.ubuntu.com/ubuntu/dists/impish/main/

The distribution code name is important

Does this sound interesting? I bet it is. Now imagine if someone is using an old, unsupported version of Ubuntu like Ubuntu 20.10 codenamed Groovy Gorilla. The sources.list file will contain repository URL like deb http://archive.ubuntu.com/ubuntu groovy main . And then it becomes problematic because if you visit http://archive.ubuntu.com/ubuntu/dists URL, you won’t find groovy folder here. Since Ubuntu 20.10 is no longer maintained, its folder has been removed. As a result, Ubuntu will show an error like ‘release file not found’ or ‘error 404 repository not found’. Did you notice that my sources.list file had some entries with focal (Ubuntu 20.04)? It’s because I had upgraded my Ubuntu 20.04 system to 20.10 to 21.04 and now to 21.10.

Читайте также:  Checking internet connection linux

sources.list file and sources.list.d directory

If you look at the /etc/apt directory, you’ll notice a directory called sources.list.d. Sources List directory in UbuntuThe idea is that the primary sources.list file is for the official Ubuntu repositories and for any external repositories and PPA, you add a .list file (with the repository details) in this sources.list.d directory. External repository information are added in sources.list.d directoryThis makes managing the repositories easier as you don’t mess up with the default repositories. The external repositories can be easily disabled (by adding # in front of the repository details) or removed (by removing its corresponding .list file). You can use the graphical Software & Updates tool for the same purpose if you use Ubuntu desktop. The entries in ‘Ubuntu Software’ tab come from the sources.list file and the entries in the ‘Other Software’ tab come from the files in sources.list.d directory. Software & Updates tool in Ubuntu

The next step

Is that clear so far? You have learned plenty of ‘behind the curtains’ things. If the entries in sources.list are incorrect or duplicated, your system will throw errors when you try to update your Ubuntu system. As you are familiar with the concept of package management, repository and sources.list, understanding the root cause and fixing the common update errors in Ubuntu becomes an easier task. Don’t just take my word for that. Put your newly learned knowledge to some good use by understanding the root cause of this error 👇 You’ll also have a better understanding of how external repositories work. Still have doubts or questions? Please leave a comment below and I’ll answer them.

Источник

Repositories / CommandLine

IconsPage/terminal.png

This page describes how to manage software repositories from the command line. (GUI tools are also available: Managing Repositories in Ubuntu or Kubuntu).

IconsPage/important.png

If you are using a minimal install or server install you will need to be familiar with a terminal based text editor like nano. If you are using a GUI install you can use Nano or GEdit.

Читайте также:  Linux which filesystem type

The Basics

Ubuntu uses apt for package management. Apt stores a list of repositories or software channels in the file

and in any file with the suffix .list under the directory

See man sources.list for more about this storage mechanism.

IconsPage/note.png

By editing these files from the command line, we can add, remove, or temporarily disable software repositories.

    Note: It’s always a good idea to backup a configuration file like sources.list before you edit it. To do so, issue the following command:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

Typically, the beginning of the file /etc/apt/sources.list looks like this:

# sources.list #deb cdrom:[Ubuntu 13.10 _Saucy Salamander_ - Release i386 (20131016.1)]/ saucy main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://ch.archive.ubuntu.com/ubuntu/ saucy main restricted deb-src http://ch.archive.ubuntu.com/ubuntu/ saucy main restricted #.

Explanation of the Repository Format

  • All the lines beginning with one or two hashes (#) are comments, for information only.
  • The lines without hashes are apt repository lines. Here’s what they say:
    • deb: These repositories contain binaries or precompiled packages. These repositories are required for most users.
    • deb-src: These repositories contain the source code of the packages. Useful for developers.
    • http://archive.ubuntu.com/ubuntu: The URI (Uniform Resource Identifier), in this case a location on the internet. See the official mirror list or the self-maintained mirror list to find other mirrors.
    • saucy is the release name or version of your distribution.
    • main & restricted are the section names or components. There can be several section names, separated by spaces.

    Other Versions

    IconsPage/note.png

    • For other Ubuntu releases you would replace the ‘saucy’ with the current version you have installed (‘precise’, ‘quantal’, ‘raring’, ‘saucy’, ‘trusty’, . ) Type lsb_release -sc to find out your release.

    Adding Repositories

    Adding the Universe and Multiverse Repositories

    deb http://us.archive.ubuntu.com/ubuntu/ saucy universe deb-src http://us.archive.ubuntu.com/ubuntu/ saucy universe deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates universe deb-src http://us.archive.ubuntu.com/ubuntu/ saucy-updates universe

    There are four similar lines for ‘multiverse’.

    sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ saucy universe multiverse" sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates universe multiverse"

    IconsPage/note.png

    Depending on your location, you should replace ‘us.’ by another country code, referring to a mirror server in your region. Check sources.list to see what is used!

    Type lsb_release -sc to find out your release. You may repeat the commands with «deb-src» instead of «deb» in order to install the source files.

    Adding Partner Repositories

    deb http://archive.canonical.com/ubuntu saucy partner deb-src http://archive.canonical.com/ubuntu saucy partner

    IconsPage/important.png

    Be aware that the software contained within this repository is NOT open source.

Adding Other Repositories

There are some reasons for which you might want to add non-Ubuntu repositories to your list of software sources. Caution: To avoid trouble with your sytem, only add repositories that are trustworthy and that are known to work on Ubuntu systems!

    You can add custom software repositories by adding the apt repository line of your software source to the end of the sources.list file. It should look something like this:

deb http://mirror3.ubuntulinux.nl/ hardy-seveas freenx

Adding Launchpad PPA Repositories

  • The command updates your sources.list file or adds/edits files under sources.list.d/. Type man add-apt-repository for detailed help.
  • If a public key is required and available it is automatically downloaded and registered.
  • Should be installed by default. On older or minimal Ubuntu releases, you may have to install software-properties-common and/or python-software-properties first (sudo apt-get install python-software-properties)

sudo add-apt-repository ppa:

Enabling Repositories with a (non-interactive) Script

IconsPage/note.png

This section seemed obsolete due to the add-apt-repository command, thus it has been removed.

Suggestions & Recommendations

  • It is always a good idea to back up configuration files like /etc/apt/sources.list before you begin editing. You can then revert your changes if needed.
  • If you decide to add other repositories to sources.list, make sure that the repository is meant to work (and known to work) with Ubuntu. Repositories that are not designed to work with your version of Ubuntu can introduce inconsistencies in your system and might force you to re-install. Also, make sure that you really need to add external repositories as the software package(s) you are looking for may already have been introduced into the official repositories!
  • Please keep in mind that it may not be legal (typically because of export restrictions) to enable some non-Ubuntu software repositories in some countries.
  • You may be asked enter a security key when adding a non-Ubuntu repository to your sources. See Managing Authentication Keys for instructions.
  • Remember to retrieve updated package lists by issuing a sudo apt-get update when you’re done editing sources.list.

Further Reading

Repositories/CommandLine (последним исправлял пользователь 2580DCEA 2015-07-27 15:42:33)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Источник

Оцените статью
Adblock
detector