This beginner's guide Part 3 talks about Ubuntu repository address settings in sources.list. By learning this article you understand what is sources.list and how to setup it according to your needs. In Ubuntu, APT will know what repository to access and what packages to download primarily based on your sources.list settings. So sources.list is very essential for your APT system. This article explains the terms (4 "channels" and 4 "rooms"), gives many practical examples, how to edit, and adds summary and references at the end. I use Ubuntu 16.10 Yakkety Yak for example in this article. And this article is a continuation of Beginner's Guide Part 2 Basic Apt-get. I hope this part is easy for everyone to understand.
Subscribe to UbuntuBuzz Telegram Channel https://telegram.me/ubuntubuzz to get article updates directly.
1. Repository
What is repository?
A repository is a place storing software packages dedicated for a
GNU/Linux operating system. Repository is created by the developer of
a GNU/Linux operating system, by transforming software from source
code into binary, producing a “package” file (.deb) for each
software. Repository is located in internet as a server, it allows
anyone to download packages. Ubuntu users download software from
Ubuntu repository. That is how it works.
To give you more
precise sense about Ubuntu repository, notice these facts: every
GNU/Linux distribution has its own repository, a repository
composed from ten of thousands packages stored in structured
directories, Ubuntu repository is divided in 4 channels and each
channels divided in 4 rooms, and a repository provides binary
and also source code version of each software.
2. Ubuntu Repository “Rooms”
Ubuntu differs from
Debian. Debian divides its repository in 3 rooms, while Ubuntu
divides its repository in 4 rooms. Debian rooms are 3: main, contrib,
and nonfree. Ubuntu rooms are 4: main, restricted, multiverse,
universe. These divisions are based on their own policies. What you
need to know here is the 4 rooms of Ubuntu repository. To give you
the (too-simplified) descriptions of them:
-
main: contains free software, maintained directly by Canonical.
-
restricted: contains nonfree software, maintained directly by Canonical.
-
universe: contains free software, maintained by community.
-
multiverse: contains nonfree software, maintained by community.
Note: please notice that this term "room" is from me, this term is unofficial.
3. Ubuntu Repository “Channels”
Ubuntu repository
composed from 4 channels, and every channel has 4 rooms mentioned
above. Each channel represents how new the software versions inside
are. The user is free to choose what channel enabled and also what
room inside channel enabled. The 4 channels of Ubuntu repository are:
-
$release: the standard channel, you can live in Ubuntu by only using this repo.
-
$release-updates: the software update channel, use this to get new version of a software.
-
$release-security: the security updates & fixes channel, use this to get security fixes quickly,
-
$release-backports: the new version from future Ubuntu release, use this to get the far more new version of a software or even new software not existed in previous Ubuntu repo.
Note: please notice that this term "channel" is also from me, this term is unofficial.
4. Ubuntu Codenames
Ubuntu has codename
to name each of its releases. Each codename has its own repository.
So if Ubuntu has 3 active releases, it means Ubuntu has 3 different
repositories. It is important because the user can not use another
version’s repository and ultimately because this codename used in
sources.list. Here is a list of Ubuntu release codenames starting
from 2012 version Ubuntu 12.04:
-
12.04 = precise
-
12.10 = quantal
-
13.04 = raring
-
13.10 = saucy
-
14.04 = trusty
-
14.10 = utopic
-
15.04 = vivid
-
15.10 = wily
-
16.04 = xenial
-
16.10 = yakkety
-
17.04 = zapty
5. Mirror
What is mirror?
A mirror is a copy of repository located somewhere else in the
internet. So there is an official repository, and there are
mirrors of official repository; they all are containing
exactly the same software packages. A mirror is created typically by
some third-parties (individuals, or universities, or companies)
willing to help the official GNU/Linux repository available more
widely. By providing a mirror, it means that users don’t need to
download software packages directly from the official repository, but
instead they can download from a local mirror repository in their
country.
A mirror created
helps the official repository server. It is clearly a form of
cooperation. It is because the amount of download connections
decreased at official server when many users switch to another
mirror.
Being able to edit sources.list settings means able to use local mirror.
6. Sources.list
What is
sources.list? A sources.list is a file containing list of
repository addresses. APT knows all available packages and where
to download them based on settings inside a sources.list. A
sources.list file is primarily important for APT and a whole Ubuntu
system to install/upgrade software. This file is located at
/etc/apt/sources.list.
7. Sources.list.d/
What is
sources.list.d/? The sources.list.d/ directory is a system
directory containing another secondary sources.list files that store
additional or third-party repository addresses. This directory is
located at /etc/apt/sources.list.d/ in Ubuntu system.
8. How To Read
There are two ways
to read sources.list: one with Terminal, one with GUI.
Terminal way:
to read a sources.list with Terminal, perform this command line
$ cat /etc/apt/sources.list | sed '/#/d; /^$/d'
and you should see
the sources.list content clearly like this (without comment lines):
GUI way: open
the program Software & Updates from Ubuntu menu or run the
command line $ software-properties-gtk. You will see the exactly same
sources.list settings but in nice GUI options. However, I do not explain the GUI way in this article.
9. How To Edit
To edit a
sources.list file, you always need root privilege. You can edit
sources.list with any text editor program you like. After editing, you should run apt-get update so APT knows the new repository address added. For example, here
you may see step-by-step editing with Gedit:
-
Run command line $ sudo gedit /etc/apt/sources.list
-
While asked, type your password anyway in Terminal
-
A Gedit window opened showing sources.list content
-
Edit some text there
-
Save
-
Exit
When you open
sources.list file with a text editor, you will see its default
content like this:
Do not get confused.
This default sources.list content indeed looks very long and complex.
But once you understand the structure (explained below) you won’t
get confused, then you may safely delete the default content and
replace it with your own settings.
Important: again, do apt-get update command every time you change the sources.list content. Without that, APT knows nothing about your newly added repository address.
10. Sources.list General Structure
This is the generic
structure of a sources.list setting. It’s like poetry. Pay
attention to the “4 rooms” and the “$release* code” in every
“stanza”. The 4 rooms mentioned means they are all enabled, the 4
release channels mentioned means they are all enabled.
deb [URL] [$release]
main
deb [URL] [$release]
restricted
deb [URL] [$release]
universe
deb [URL] [$release]
multiverse
deb [URL]
[$release-updates] main
deb [URL]
[$release-updates] restricted
deb [URL]
[$release-updates] universe
deb [URL]
[$release-updates] multiverse
deb [URL]
[$release-security] main
deb [URL]
[$release-security] restricted
deb [URL]
[$release-security] universe
deb [URL]
[$release-security] multiverse
deb [URL]
[$release-backports] main
deb [URL]
[$release-backports] restricted
deb [URL]
[$release-backports] universe
deb [URL]
[$release-backports] multiverse
11. Sources.list General Structure, Simplified
The very long
generic structure above can be simplified into only 4 lines like
this. Pay attention in how 4 rooms written, and how the 4 channels is
located. This general structure enabled all channels and all rooms in
Ubuntu repository.
deb [URL] [$release]
main restricted universe multiverse
deb [URL]
[$release-updates] main restricted universe multiverse
deb [URL]
[$release-security] main restricted universe multiverse
deb [URL]
[$release-backports] main restricted universe multiverse
12. Sources.list General Example
Now, you should
understand how to use that generic structure in a real sources.list.
For this purpose, I show you here two examples of sources.list: one
for 16.10 yakkety and one for 12.04 precise. Both have all channels
and rooms enabled. Pay attention to how [$release*]
code replaced, and how [URL] changed. This method of setting is
applicable to all Ubuntu release versions.
Sources.list for
yakkety:
deb http://id.archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiversedeb http://id.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiversedeb http://security.ubuntu.com/ubuntu/ yakkety-security main restricted universe multiversedeb http://id.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse
Sources.list for
precise:
deb http://id.archive.ubuntu.com/ubuntu/ precise main restricted universe multiversedeb http://id.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiversedeb http://security.ubuntu.com/ubuntu/ precise-security main restricted universe multiversedeb http://id.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
13. Disabling Repository Component
To manage
sources.list means to enable/disable repository's certain component.
Every user is free to disable any channel and any room of Ubuntu
repository, and vice versa. To disable one, you just need to type '#' on the beginning of line or delete any room as you wish. Then, by changing this sources.list, APT
will only download software packages from the repository
channels/rooms you chose. In other words, APT obeys you based on
your sources.list setting. Here are some examples:
a) Disabling all
channels except standard channel:
deb http://id.archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse#deb http://id.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiverse#deb http://security.ubuntu.com/ubuntu/ yakkety-security main restricted universe multiverse#deb http://id.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse
b) Disabling only
backports channel:
deb http://id.archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiversedeb http://id.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiversedeb http://security.ubuntu.com/ubuntu/ yakkety-security main restricted universe multiverse#deb http://id.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse
c) Disabling all
nonfree rooms:
deb http://id.archive.ubuntu.com/ubuntu/ yakkety main universedeb http://id.archive.ubuntu.com/ubuntu/ yakkety-updates main universedeb http://security.ubuntu.com/ubuntu/ yakkety-security main universedeb http://id.archive.ubuntu.com/ubuntu/ yakkety-backports main universe
d) Disabling all
rooms except main room:
deb http://id.archive.ubuntu.com/ubuntu/ yakkety maindeb http://id.archive.ubuntu.com/ubuntu/ yakkety-updates maindeb http://security.ubuntu.com/ubuntu/ yakkety-security maindeb http://id.archive.ubuntu.com/ubuntu/ yakkety-backports main
14. How It Looks
Because this article
is for beginners, here I show you how it looks when sources.list
changed using (a) and (c) examples above. I use Gedit as text editor
here.
a) Disabling all
channels except standard channel:
c) Disabling all
nonfree rooms:
15. Source Code Repository
Ubuntu GNU/Linux distribution distributes software in binary form and
also source code form. This means Ubuntu has binary repo and also
source code repo at the same time for each release. What I mentioned
above is all about binary repo, they are composed of .deb
packages. So I mention here about source code repo, the repo composed
from .tar.gz packages. Every Ubuntu user receives the right to
access source code of every part of Ubuntu GNU/Linux distribution
completely. So whenever you need or you wanna try source code, you
can enable the source code repo. This section give you the basic
understanding about it.
This is binary repo address setting:
deb http://id.archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse
This is source code repo address setting:
deb-src http://id.archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse
Notice the only difference now is the deb-src code at the beginning
of line. The deb code represents binary repo, while you use it then
you enable the binary repo. And the deb-src code represents source
code repo (source = src), while you use it then you enable the source
code repo.
16. Enabling Source Code Repository
To enable any source code repository is just exactly the same as
enabling any binary repository previously. You only need to change
deb into deb-src. Here is the example for complete 4x4 channelsxrooms
repositories enabled both for binary and source:
deb
http://id.archive.ubuntu.com/ubuntu/ yakkety main restricted universe
multiverse
deb
http://id.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted
universe multiverse
deb
http://security.ubuntu.com/ubuntu/ yakkety-security main restricted
universe multiverse
deb http://id.archive.ubuntu.com/ubuntu/ yakkety-backports main
restricted universe multiverse
deb-src
http://id.archive.ubuntu.com/ubuntu/ yakkety main restricted universe
multiverse
deb-src
http://id.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted
universe multiverse
deb-src
http://security.ubuntu.com/ubuntu/ yakkety-security main restricted
universe multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ yakkety-backports main
restricted universe multiverse
Pay attention at two "stanzas" above: they are both the same except
deb-src is for source code. Those two stanzas enable both binary and
source code repositories, enable 4 rooms in every of 4 channels; in
other words, this setting is the most complete
all-repositories-enabled possible for Ubuntu.
To disable any of them, just use the same disabling method (using '#') already
explained.
17. Summary
Here is a summary of this whole Part 3 Sources.list Settings
article.
-
Sources.list is repository address setting for APT.
-
Once a sources.list changed, apt-get update should be invoked.
-
To disable an address, put ‘#’ character on the beginning of its line.
-
To re-enable an address, remove ‘#’ character on the beginning of line.
-
Ubuntu sources.list composed from 4 channels with 4 rooms each.
-
Ubuntu sources.list composed from binary (deb) and source code (deb-src) repositories.
-
Ordinary users generally just need binary repositories (deb) for 4 channel x 4 rooms.