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?
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
I know that’s not easy to understand. Let’s take a look at one of the actual lines:
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).
Next, 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.
The component is one of the five types of default Ubuntu repositories.
You 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
You write two of them together like this:
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.
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.
The 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.
This 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.
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.