What is sources.list ?

posted on
by Mohamad Wael

The /etc/apt/sources.list file contains a list of sources from which apt can download indexes of binary and source packages. Each source in the list has the following format :

enlighterType URI distribution [component1] [component2] [...]
sources.list what is / format : type , URI , distribution , component

Type

Type can be either deb, or deb-src.

			
deb http://deb.debian.org/debian/ buster main
# deb :  is the Type of indexes to get  , 
#	deb is used to get indexes of binary
#	packages .
# http:// : URI scheme .
# deb.debian.org/debian/ : repository address.
# buster : is the distribution .
# main : is the component .
deb-src http://deb.debian.org/debian/ buster main
# deb-src : is the Type of indexes to get , 
#	deb-src is used to get indexes of source 
#	packages.
# http:// : URI scheme .
# deb.debian.org/debian/ : repository address.
# buster : is the distribution .
# main : is the component .
					

deb is used to indicate that we want to download indexes of binary packages. Binary packages can be either .deb or .udeb packages . .deb packages are used to install applications , commands , utilities … .udeb packages are used to add capabilities to the installer .

Indexes of binary packages are stored in files named Packages.[gz|xz|bz2] on the repository URI , where gz or xz or bz2 is the compression that is used . For each distribution / component / architecture we have an index of binary packages.

		
# index of deb packages
dists/$DIST[/folder]/$COMP/binary-$ARCH/Packages.[gz|xz]
# Packages.[gz|xz] is an index of .deb packages . 
# dists is the dists folder under the repository .
# $DIST is a folder that has the  
#	distribution suite name 
#	for example stable ,  or 
#	codename for example  buster …
# [/folder] is an optional folder in the 
#	the $DIST folder , for example it can 
#	be updates.
# $COMP is a folder  with the component 
# 	name  , for example contrib or main …
# binary-$ARCH , is a folder where $ARCH
# 	is the architecture name  , for example 
# 	binary-amd64 , binary-mips …
# As an example , the location of the 
# 	index of deb binary packages  , for the 
# 	amd64 architecture , contrib component, 
# 	stable distribution suite ,  and 
# 	https://deb.debian.org/debian/ repository 
# 	is 
# 	https://deb.debian.org/debian/dists/stable/contrib/binary-amd64/Packages.xz
# Another example , the location of the 
#	index of deb binary packages  , for the 
#	amd64 architecture  non-free component, 
#	in the update folder of the
#	stable distribution suite, 
#	in the
#	http://security.debian.org/debian-security  repository 
#	is 
#	http://security.debian.org/debian-security/dists/stable/updates/non-free/binary-amd64/Packages.gz

# index of udeb packages
dists/$DIST[/folder]/$COMP/debian-installer/binary-$ARCH/Packages.[gz|xz]
# Packages.[gz|xz] is an index of .udeb packages . 
# dists is the dists folder under the repository .
# $DIST is a folder that has the  
#	distribution suite name for 
#	example stable ,  
#	or codename for example  buster …
# [/folder] is an optional folder in the 
#	the $DIST folder , for example it can 
#	be updates.
# $COMP is a folder  with the component 
# 	name  , for example contrib or main …
# debian-installer is a folder inside 
# 	the $COMP folder .
# binary-$ARCH , is a folder where $ARCH
# 	is the architecture name  , for example 
# 	binary-amd64 , binary-mips …
# As an example , the location of the 
# 	index of udeb binary packages  , for the 
# 	amd64 architecture , contrib component, 
# 	stable distribution suite ,  and 
# 	https://deb.debian.org/debian/ repository 
# 	is 
# 	https://deb.debian.org/debian/dists/stable/contrib/debian-installer/binary-amd64/Packages.xz
					

Indexes of binary packages contain descriptions of .deb or .udeb packages . Each description consists of the Filename , Package name , Version number … The Filename contains the location from which we can download a package relative to the current repository … For example :

			
Package: 0ad-data
Version: 0.0.23.1-1
Installed-Size: 2044173
Maintainer: Debian Games Team <pkg-games-devel@lists.alioth.debian.org>
Architecture: all
Pre-Depends: dpkg (>= 1.15.6~)
Suggests: 0ad
Description: Real-time strategy game of ancient warfare (data files)
Homepage: http://play0ad.com/
Description-md5: 26581e685027d5ae84824362a4ba59ee
Tag: role::app-data
Section: games
Priority: optional
Filename: pool/main/0/0ad-data/0ad-data_0.0.23.1-1_all.deb
Size: 701878080
MD5sum: 48a0f2d3af77e4cf01638e4429bddbd8
SHA256: 0fa3fb9ef1999054d041f2425b677312e4d4e7bf43ac499665f7f69a21f8b0a9
					

deb-src is used to indicate that we want to download indexes of source packages . A source package is a .dsc package . .dsc packages are used to install the source code of applications , commands , utilities …

Indexes of source packages are stored in files named Sources.[gz|xz|bz2] on the repository URI , where gz or xz or bz2 is the compression that is used . For each distribution / component we have an index of source packages.

		
# index of source packages
dists/$DIST[/folder]/$COMP/source/Sources.[gz|xz]
# Sources.[gz|xz] is an index of .dsc packages . 
# dists is the dists folder under the repository .
# $DIST is a folder that has the 
#	distribution suite name for example stable , 
# 	or codename for example  buster …
# [/folder] is an optional folder in the 
#	the $DIST folder , for example it can 
#	be updates.
# $COMP is a folder  with the component 
# 	name  , for example contrib or main …
# source , is a folder under the $comp 
#	folder.
# As an example , the location of the 
#	index of dsc source packages  , for the 
#	main component,
#	stable distribution suite ,  and 
#	https://deb.debian.org/debian/ repository 
#	is 
#	https://deb.debian.org/debian/dists/stable/main/source/Sources.xz
# Another example , the location of the 
#	index of dsc source packages  , for the 
#	contrib component, in the updates
#	folder of the oldstable distribution 
#	suite , in the  
#	http://security.debian.org/debian-security repository 
#	is 
#	http://security.debian.org/debian-security/dists/oldstable/updates/contrib/source/Sources.gz
					

Source packages indices contain the description of .dsc package . Each description consists of the Package name , its Version number , its Binary package , the Directory where we can download this source package relative the the current repository …

	
Package: 0ad
Binary: 0ad
Version: 0.0.23.1-2
Maintainer: Debian Games Team <pkg-games-devel@lists.alioth.debian.org>
Uploaders: Vincent Cheng <vcheng@debian.org>, Ludovic Rousseau <rousseau@debian.org>
Build-Depends: autoconf, debhelper (>= 10), dpkg-dev (>= 1.15.5), libboost-dev, libboost-filesystem-dev, libcurl4-gnutls-dev | libcurl4-dev, libenet-dev (>= 1.3), libgloox-dev (>= 1.0.10), libicu-dev, libminiupnpc-dev (>= 1.6), libnspr4-dev, libnvtt-dev (>= 2.0.8-1+dfsg-4~), libogg-dev, libopenal-dev, libpng-dev, libsdl2-dev (>= 2.0.2), libsodium-dev (>= 1.0.14), libvorbis-dev, libwxgtk3.0-dev | libwxgtk2.8-dev, libxcursor-dev, libxml2-dev, pkg-config, python, python3, zlib1g-dev
Architecture: amd64 arm64 armhf i386 kfreebsd-amd64 kfreebsd-i386
Standards-Version: 4.1.4
Format: 3.0 (quilt)
Files:
 00145aa3a05b2013a7232b5c5a800a84 2473 0ad_0.0.23.1-2.dsc
 4fa111410ea55de7a013406ac1013668 31922812 0ad_0.0.23.1.orig.tar.xz
 1c472844ea3bf28a875b7c6031e395f3 71708 0ad_0.0.23.1-2.debian.tar.xz
Vcs-Browser: https://salsa.debian.org/games-team/0ad
Vcs-Git: https://salsa.debian.org/games-team/0ad.git
Checksums-Sha256:
 6af5313fb7c875c5aa4fdbcb6beb17131b60d6c440e59e2a14409688e8442744 2473 0ad_0.0.23.1-2.dsc
 01bff7641ee08cac896c54d518d7e4b01752513105558f212e3199d747512a37 31922812 0ad_0.0.23.1.orig.tar.xz
 fe4a1943e2fa9fca4f9fa8f43e0e32f287bd2bbf93df1c7497b734784375fe46 71708 0ad_0.0.23.1-2.debian.tar.xz
Homepage: http://play0ad.com/
Package-List: 
 0ad deb games optional arch=amd64,arm64,armhf,i386,kfreebsd-amd64,kfreebsd-i386
Directory: pool/main/0/0ad
Priority: source
Section: games
					

We can pass options to Type . The format of the options is Type [ option1=value1 option2=value2 … ]. An option can have more than one value , separated by comma. The specified options affects which indexes apt will download , and how these indexes are downloaded .

For example the arch option specify the architecture of the indices that will be downloaded . The default architecture is the architecture that the apt program was compiled for .

# arch option , for the deb type				
deb [ arch=amd64,i386 ] http://deb.debian.org/debian buster main
# deb  : get indexes of binary packages 
# [ arch=amd64,i386 ]  : get the indexes for 
#	the amd64 and i386 architecture.
# http:// : URI scheme. 
# deb.debian.org/debian : repository location. 
# buster : distribution .
# main : component .
# The .deb indexes that apt will download  are :
#	http://deb.debian.org/debian/dists/buster/main/binary-amd64/Packages.xz
#	http://deb.debian.org/debian/dists/buster/main/binary-i386/Packages.xz
					

The by-hash option specifies how apt will download the indices . If set to yes apt will download the indices by using their hash sums and not their names if the server supports it. If the server does not support it then apt will download the indices by their names. The default value for this option is yes.

# by-hash option , for the deb type				
deb [ arch=amd64 by-hash=yes ] http://deb.debian.org/debian buster main
# deb  : get indexes of binary packages 
# [ arch=amd64 ]  : get the indexes for 
#	the amd64 architecture .
# [ by-hash=yes ]  : 
#	download the indexes by 
#	hash sum if the server supports it , 
#	else download the indexes by their name. 
# http:// : URI scheme. 
# deb.debian.org/debian : repository location. 
# buster : distribution .
# main : component .
# The .deb index that apt will download,
#	if the server does not support by-hash : 
#		http://deb.debian.org/debian/dists/buster/main/binary-amd64/Packages.xz
#	if the server supports by hash , and if 
#		for example the md5 hash of  
#		Packages.xz is 1f005105b180e13e020edd09044d24ed
#		apt will download :
# 			http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/MD5Sum/1f005105b180e13e020edd09044d24ed

					

URI

URI is a uniform resource identifier , it is the address of the repository from which we can download the .deb , .udeb , .dsc packages and the packages indexes .

The URI scheme can be for example http(s) or ftp or it can be file or cdrom … A file URI is used to specify that the repository is located under the local file system . A cdrom URI is used to indicate that the repository is located on a cd-rom . For example :

			
# source
deb cdrom:[Debian GNU/Linux 10.1.0 _Buster_ - Official amd64 xfce-CD Binary-1 20190908-01:08]/ buster main
# deb : type of indexes to get is  Packages.[xz|gz] .
# cdrom: is the  URI Scheme
# Debian GNU/Linux 10.1.0 _Buster_ - Official amd64 xfce-CD Binary-1 20190908-01:08]/ : 
#	Label of the cdrom .
# buster : is the distribution code name .
# main : is the  component .
# If we want to add  a cdrom repository , 
#	we must use apt-cdrom  , we cannot 
#	add a cd-rom repository
#	by hand .

# source
deb-src http://deb.debian.org/debian/ buster main
# deb-src : type of indexes to get is Sources.[xz|gz] .
# http::// : is the URI  scheme.
# deb.debian.org/debian/ : is the repository location .
# buster : is the distribution codename .
# main : is the component .

# source
deb file:/var/opt/apt/debian stable main contrib non-free
# deb :  type of indexes to get is  Packages.[xz|gz] .
# file:/ : is the URI  scheme.
# /var/opt/apt/debian  : is the location of the 
#	repository on the local filesystem .
# stable : is the distribution suite name .
# main contrib non-free : are the components .
					

For each distribution , the repository contains a release file . The release file can either be a Release file or an InRelease file , or it can be both. An InRelease file has the gpg signature inside, whereas a Release file has the gpg signature in a separate file called Release.gpg .

	
#Release , InRelease file
dists/$DIST[/folder]/(Release InRelease)
# dists is the dists folder under the repository .
# $DIST is a folder that has the  
#	distribution suite name for example stable ,  
#	or codename for example  buster …
# [/folder] is an optional folder in the 
#    the $DIST folder , for example it can 
#    be updates.
# Release , InRelease , are the 
# distribution release files .
# As an example , the location of the 
#	Release , InRelease files for the stable 
#	distribution under 
#	the https://deb.debian.org/debian/ repository is 
#	https://deb.debian.org/debian/dists/stable/Release 
#	https://deb.debian.org/debian/dists/stable/InRelease .
# And the location of the Release , InRelease 
#	files for the 
#	oldstable distribution under the 
#	http://security.debian.org/debian-security repository
#	is
#	http://security.debian.org/debian-security/dists/oldstable/updates/Release
#	http://security.debian.org/debian-security/dists/oldstable/updates/InRelease
					

The release file contains the location of the indices, such as the Sources and Packages indexes, relative to the release file . The release file also contain the indexes sizes and hash , the release Suite name , Codename , supported Architectures and Components

Origin: Debian
Label: Debian
Suite: testing
Codename: bullseye
Changelogs: https://metadata.ftp-master.debian.org/changelogs/@CHANGEPATH@_changelog
Date: Fri, 20 Dec 2019 14:23:46 UTC
Valid-Until: Fri, 27 Dec 2019 14:23:46 UTC
Acquire-By-Hash: yes
Architectures: amd64 arm64 armel armhf i386 mips64el mipsel ppc64el s390x
Components: main contrib non-free
Description: Debian x.y Testing distribution - Not Released
MD5Sum:
…
…
 a23a4a0a6ab43214c62f6ac17ffe32d6   220436 contrib/binary-amd64/Packages
 c531d3d5d045016d0de9629cd8ccb9da    27796 contrib/binary-amd64/Packages.diff/Index
 2a2aad47dab208dcc2d1eb0f23bac959    58313 contrib/binary-amd64/Packages.gz
 551469cac92c7ed6723ece072fde5cf5    48944 contrib/binary-amd64/Packages.xz
…
…
 dbee9f10ee1ae6871c9001eaaf5984c7    62246 main/debian-installer/binary-all/Packages
 bb0343b04c11366d04fa11fbb4667159    16726 main/debian-installer/binary-all/Packages.gz
 dc88ecb66365af3b6be8d0c86f568103    14920 main/debian-installer/binary-all/Packages.xz
 …
 …
 a65c8a655440b59f771df0c5292dcf32   377987 non-free/source/Sources
 550ca03e6b58ff6a8f69855df2caa581    27796 non-free/source/Sources.diff/Index
 b39c540b9c9e3ffa59e5db90a46865f5   103201 non-free/source/Sources.gz
 c2ba1543814c26b65eb286b5925e5698    86152 non-free/source/Sources.xz
 …
 …
					

Distribution

A distribution can either be a Suite name , or a Codename . A distribution has a Release file and It can have multiple architectures and components . Its release file can contain its version number and origin , its suite name and code name , its components and supported architectures …

The Suite names are the experimental , the unstable , the testing , the stable , and the oldstable .

The experimental distribution contains package in alpha stage , or package that are being developed , and tested. The experimental distribution is not a release , so there are no installation cds , we can install packages from this distributions , but this is more for alpha testing.

The unstable is where new package are introduced , and where packages are updated. We can think of unstable as being the beta stage. The packages keep on being updated and tested and new features are added. There is no release for the unstable distribution , so there is no a cd to install this distribution . The unstable repository is updated every six hours.

The testing distribution , is the release candidate distribution . After the packages have spent a period of time in the unstable distribution , and after being checked for having no critical bugs , and that they don't break any package , and that they have their dependencies satisfied , packages are moved to the testing distribution . There are weekly builds of the testing distribution , so we can install it by using a cd or dvd .

After about two years from the previously released stable distribution , the testing distribution becomes the new stable distribution. Before becoming stable , the testing distribution is frozen for around seven month . In the freeze period no new package are introduced or updated without the approval of the release manager .

The stable distribution is the current stable release , when testing becomes stable , stable is moved to oldstable , oldstable is kept for around one year before being moved to archive .

A Suite has a Codename , the Codename is based on characters from the Toy Story movie . The experimental suite has always the experimental code name , the unstable suite has always the code name sid . Other examples of Codename for the testing , stable , oldstable suites are : bullseye , buster , jessie .

Security Updates

Some distributions receive security updates from the security team . The oldstable will receive security updates from the security team for one year after becoming the oldstable . The stable distribution will receive security updates till it becomes the oldstable . The testing distribution will receive security updates for packages that take too long to reach the testing distribution.

The security team security updates are located in a separate repository.

		
#security team updates 
deb http://security.debian.org/debian-security buster/updates main
# deb  : get indexes of debian binary package .
# http:// : scheme of this repository is http:// .
# security.debian.org/debian-security : 
#	the location of the repository for the 
#	security updates.
# buster/updates : 
#	the distribution codename is buster ,
#	and the release files are located inside the 
#	updates folder of the buster distribution. 
# main : the component is the main component.
# For example , The Release files containing 
#	the indexes for the main component of 
#	the buster distribution from the security 
#	team are located under :
#	http://security.debian.org/debian-security/dists/buster/updates/Release
#	http://security.debian.org/debian-security/dists/buster/updates/InRelease

	
                        

Suite or Codename extension

A Suite or a Codename can have extensions .

The testing, stable and oldstable distributions or Codename can have the updates extension. For example :

		
stable-updates
testing-updates
buster-updates
                        

The updates extension contains a distribution packages critical bugs updates. It also contains updates for packages that have changed , for example antivirus databases .

		
# buster-updates extension
deb http://deb.debian.org/debian/ buster-updates main
# deb : get the index of binary packages .
# http:// : repository scheme .
# deb.debian.org/debian/ : repository address.
# buster-updates : distribution extension .
# main :  the main component .
# For example the Release , InRelease files for the 
#	buster-updates extension 
#	are located at :
#	http://deb.debian.org/debian/dists/buster-updates/Release
#	http://deb.debian.org/debian/dists/buster-updates/InRelease
                        

The release manager supervises the updates that are included in the oldstable and stable distribution.

The testing, stable and oldstable distributions or Codename can also have the proposed-updates extension. For example :

		
oldstable-proposed-updates
testing-proposed-updates
buster-proposed-updates
                        

The proposed-updates extension contains the security updates from the security team , the critical bugs updates from the updates extension , and other packages updates that are not grave or serious .

		
# oldstable-proposed-updates extension
deb http://deb.debian.org/debian/ oldstable-proposed-updates main
# deb : get the index of binary packages .
# http:// : repository scheme .
# deb.debian.org/debian/ : repository address.
# oldstable-proposed-updates : distribution extension .
# main :  the main component .
# For example the Release , InRelease files for the 
#    oldstable-proposed-updates extension 
#    are located at :
#    http://deb.debian.org/debian/dists/oldstable-proposed-updates/Release
#    http://deb.debian.org/debian/dists/oldstable-proposed-updates/InRelease
                        

The release manager oversees what is included in the oldstable-proposed-updates and stable-proposed-updates extensions . Every two month , the release manager will release , a point release for the oldstable and stable distributions containing all the updates in the proposed-updates extension .

The testing, stable and oldstable distributions or Codename can also have the backports extension . The oldstable-backports contains package from the stable distribution that are compiled without the libraries and back ported to the oldstable distribution. The stable-backports contains package from the testing distribution that are compiled without the libraries and back ported to the stable distribution. The testing-backports contains package from the unstable distribution that are compiled without the libraries and back ported to the testing distribution.

		
# stable-backports extension
deb http://deb.debian.org/debian/ stable-backports main
# deb : get the index of binary packages .
# http:// : repository scheme .
# deb.debian.org/debian/ : repository address.
# stable-backports : distribution extension .
# main :  the main component .
# For example the Release , InRelease files for the 
#    stable-backports distribution extension 
#    are located at :
#    http://deb.debian.org/debian/dists/stable-backports/Release
#    http://deb.debian.org/debian/dists/stable-backports/InRelease
                        

The oldstable distribution can also have the backports-sloppy extension . The oldstable-backports-sloppy extension contains compiled package from the testing distribution , without the libraries , and which are back ported to the oldstable distribution .

		
# oldstable-backports-sloppy extension
deb http://deb.debian.org/debian/ oldstable-backports-sloppy main
# deb : get the index of binary packages .
# http:// : repository scheme .
# deb.debian.org/debian/ : repository address.
# oldstable-backports-sloppy : distribution extension .
# main :  the main component .
# For example the Release , InRelease files for the 
#    oldstable-backports-sloppy extension 
#    are located at :
#    http://deb.debian.org/debian/dists/oldstable-backports-sloppy/Release
#    http://deb.debian.org/debian/dists/oldstable-backports-sloppy/InRelease
                        

Component

A distribution can have multiple components . The available components are the main, non-free and contrib. They are distinguished based on their license.

The main component contains the packages that follow the Debian free software guidelines. So they are the packages which have their source code included , that allow modification , derived work, free redistribution , and that do not disfavor individuals , groups , or commercial use … They are also the packages which are released under a free license such as GPL or BSD

The non-free component contains package that are not free based on Debian free software guidelines. For example , closed source packages , no commercial use , no derived work allowed …

The contrib component contains packages that are open source but that needs non-free ingredients to work . For example packages that use a closed source library or a closed source driver …

	
			
# main , non-free and contrib components
deb http://deb.debian.org/debian/ stable main non-free contrib
# deb :  type of indexes to get is Packages.[xz|gz] .
# http:// : is the URI  scheme.
# deb.debian.org/debian/  : 
#	is the location of the 
#	repository .
# stable : is the distribution suite name .
# main non-free contrib : are the components .
# For example , for the amd64 architecture 
#	the .deb indexes that apt will download 
#	for each of the main non-free contrib
#	components are : 
#		http://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz
#		http://deb.debian.org/debian/dists/stable/non-free/binary-amd64/Packages.xz
#		http://deb.debian.org/debian/dists/stable/contrib/binary-amd64/Packages.xz

				

sources.list example

This is an example of /etc/apt/sources.list file . It contains a source for the point release , a source for security updates , a source for updates , a source for backported packages , and a source for experimental packages .

			
#/etc/apt/sources.list
deb http://deb.debian.org/debian/ stable main
deb-src http://deb.debian.org/debian/ stable main
# Download the binary and source packages indices 
# for the stable point release main component.
# A point release is updated every two months.

deb http://security.debian.org/debian-security stable/updates main
deb-src http://security.debian.org/debian-security stable/updates main
# Download the security updates 
# binary and source packages indices 
# for the stable distribution main component 
# from the the security-team.


deb http://deb.debian.org/debian/ stable-updates main
deb-src http://deb.debian.org/debian/ stable-updates main
# Download the critical bugs updates
# binary and source packages indices 
# for the stable distribution .

deb http://deb.debian.org/debian/ stable-backports main
deb-src http://deb.debian.org/debian/ stable-backports main
# Download the back ports 
# binary and source packages indices 
# for the stable distribution .

deb http://deb.debian.org/debian/ experimental main
deb-src http://deb.debian.org/debian/ experimental main
# Download the binary and source packages indices 
# for the experimental distribution. 
# The experimental distribution contains 
# experimental packages that are bing tested
# and developed . 

					

We can update the indices of the local machine , by issuing the following command :

			
@debian:~$ apt-get update 
# update binary and sources
# indices of  the local machine .
Hit:1 http://deb.debian.org/debian stable InRelease
Hit:2 http://security.debian.org/debian-security stable/updates InRelease
Hit:3 http://deb.debian.org/debian stable-updates InRelease
Hit:4 http://ftp.debian.org/debian buster-backports InRelease
Hit:5 http://deb.debian.org/debian stable-backports InRelease
Hit:6 http://deb.debian.org/debian experimental InRelease
Reading package lists... Done
W: Conflicting distribution: http://deb.debian.org/debian stable-backports InRelease (expected stable-backports but got buster-backports)
# The warning is just stating that the currently
# stable distribution  has the code name 
# buster . 
# When  we have downloaded the  InRelease file for the
# stable-backports extension ,  we have actually 
# downloaded the  InRelease file for the 
# buster-backports  extension  , buster  is 
# the current stable distribution .

					

By default , packages from the experimental distribution and from the backports extension have lower priority than other packages, so they will not be automatically installed if other packages are available . For example , the redis package is currently available in the stable , stable-backports , and experimental distributions.

			
@debian$ apt show -a redis
# apt show : show information about a 
#	package.
# -a : show information about all
#	versions of a package .
# redis : name of the package to 
#	show information about

Package: redis
Version: 5:6.0~rc1-1
Priority: optional
Section: database
Maintainer: Chris Lamb <lamby@debian.org>
Installed-Size: 32.8 kB
Depends: redis-server (<< 5:6.0~rc1-1.1~), redis-server (>= 5:6.0~rc1-1)
Homepage: https://redis.io/
Download-Size: 20.6 kB
APT-Sources: http://deb.debian.org/debian experimental/main amd64 Packages
Description: Persistent key-value database with network interface (metapackage)
 This package depends on the redis-server package.
# redis package version 5:6.0~rc1-1 from 
# the experimental distribution .

Package: redis
Version: 5:5.0.7-1~bpo10+1
Priority: optional
Section: database
Maintainer: Chris Lamb <lamby@debian.org>
Installed-Size: 63.5 kB
Depends: redis-server (<< 5:5.0.7-1~bpo10+1.1~), redis-server (>= 5:5.0.7-1~bpo10+1)
Homepage: https://redis.io/
Download-Size: 51.7 kB
APT-Sources: http://deb.debian.org/debian stable-backports/main amd64 Packages
Description: Persistent key-value database with network interface (metapackage)
# redis package version 5:5.0.7-1~bpo10+1 from 
# the stable-backports extension .

Package: redis
Version: 5:5.0.3-4+deb10u1
Priority: optional
Section: database
Maintainer: Chris Lamb <lamby@debian.org>
Installed-Size: 56.3 kB
Depends: redis-server (<< 5:5.0.3-4+deb10u1.1~), redis-server (>= 5:5.0.3-4+deb10u1)
Homepage: https://redis.io/
Download-Size: 45.1 kB
APT-Sources: http://deb.debian.org/debian stable/main amd64 Packages
Description: Persistent key-value database with network interface (metapackage)
 This package depends on the redis-server package.
# redis package version 5:5.0.3-4+deb10u1 from 
# the stable distribution .

					

If we try to install the redis package , the redis package from the stable distribution will be installed .

To install a package from the experimental distribution and from the backports extension , when other version of this package exits , we can use the -t option.

			
apt-get install -t (distribution) package-name
# apt-get : handles package installation ,
#	updates …
# install : command for apt-get to 
#	install a package .
# -t :  option for apt-get to select 
#	the distribution from which to 
#	install a package  .
# (distribution) :  the distribution Suite ,
#	or Codename from which to install a 
#	a package. For example experimental , 
#	or buster-backports …
#	We cannot use oldstable-backports , 
#	stable-backports or testing-backports with 
#	this option. Instead we must use the code 
#	name. For example the current codename 
#	for stable is buster , so 
#	instead of using stable-backports
#	we must use buster-backportrs .
# package-name : the package-name that we 
#	want to install.
# We can use su or sudo to become root user 
#	before installing a package  .
					

So to install the redis package from the buster-backports extension , we can issue the following command as a root.

			
@debian:~$ apt-get install -t buster-backports redis
# install the redis package from the 
# buster-backports extension .
# buster is the current stable distribution, 
# so buster-backports contains packages 
# from the testing distribution which are 
# compiled without the libraries and ported 
# to buster . 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libhiredis0.14 libjemalloc2 lua-bitop lua-cjson redis-server redis-tools
Suggested packages:
  ruby-redis
The following NEW packages will be installed:
  libhiredis0.14 libjemalloc2 lua-bitop lua-cjson redis redis-server
  redis-tools
0 upgraded, 7 newly installed, 0 to remove and 99 not upgraded.
Need to get 954 kB of archives.
After this operation, 3,586 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
					

If we try to install a package from the experimental distribution , the package is not compiled without the libraries and back ported to the current distribution , it is compiled for the experimental distribution, and it depends on libraries from either the experimental or unstable distribution . So we might get errors when installing a package from the experimental distribution , for example because some packages have not yet been created. Installing package from the experimental distribution might also break other packages in the current distribution .

	
@debian:~$ apt-get install -t experimental redis redis-server redis-tools libc6 libcrypt1
# installing the redis package from the 
# experimental distribution , will fail   
# because libcrypt1 has no 
# installation candidate.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libcrypt1 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libcrypt1' has no installation candidate
### install redis package from the ###
### experimental distribution ###


@debian:~$ apt-get install -t experimental e3
# we can install the e3 package from 
# the experimental distribution , 
# it does not depend on any other package
# or library. 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  e3
0 upgraded, 1 newly installed, 0 to remove and 136 not upgraded.
### install e3 package from the experimental ###
### distribution ###


					

If other packages are not available from other distributions , the package from the experimental distribution or backports extension will be automatically installed.

@debian:~$ apt-get install clang-10-doc 
# There are no other versions of the 
# clang-10-doc packages , as such it is 
# not necessary to specify that we 
# want to install it from the experimental 
# distribution by using -t .
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  clang-10-doc
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 0 B/1,049 kB of archives.
After this operation, 8,399 kB of additional disk space will be used.
Selecting previously unselected package clang-10-doc.
(Reading database ... 125810 files and directories currently installed.)
Preparing to unpack .../clang-10-doc_1%3a10~+201911120943210600592dd459242-1~exp1_all.deb ...
Unpacking clang-10-doc (1:10~+201911120943210600592dd459242-1~exp1) ...
Setting up clang-10-doc (1:10~+201911120943210600592dd459242-1~exp1) ...

					

Packages from the experimental distribution are not automatically updated , packages from the backports extensions can be automatically updated .

If we want to use more than one distribution in a sources.list other than the experimental distribution or backports extensions, so for example if we want to use both the stable and testing distributions in the sources.list , then we must use an apt preferences files to control the version of the package to be installed .

What is sources.list.d ?

Instead of adding the sources to the /etc/apt/sources.list file , it is preferable to add them to the /etc/apt/sources.list.d/ directory. The sources.list.d directory , can contain zero or more files , ending with the .list extension . Each file in the sources.list.d directory contains a list of sources , where each source has the format Type URI distribution [component1] [component2] [...] . The name of the files in sources.list.d directory can consist only of [a-zA-Z0-9_-.]

	
#/etc/apt/sources.list	
deb http://deb.debian.org/debian/ stable main
deb-src http://deb.debian.org/debian/ stable main
# stable distribution .

deb http://security.debian.org/debian-security stable/updates main
deb-src http://security.debian.org/debian-security stable/updates main
# stable distribution security updates.

deb http://deb.debian.org/debian/ stable-updates main
deb-src http://deb.debian.org/debian/ stable-updates main
# stable-updates extension ,
# contains critical bugs updates 
# for packages in the stable
# distribution.


#/etc/apt/sources.list.d/stable-backports.list
deb http://deb.debian.org/debian/ stable-backports main
deb-src http://deb.debian.org/debian/ stable-backports main
# stable-backports extension ,  
# contains packages that are back
# ported to the stable distribution
# from the testing distribution .


#/etc/apt/sources.list.d/experimental.list
deb http://deb.debian.org/debian/ experimental main
deb-src http://deb.debian.org/debian/ experimental main
# experimental distribution,
# contains experimental packages .

@debian:~$ apt-get update
# update the indices 
Hit:1 http://deb.debian.org/debian stable InRelease
Hit:2 http://security.debian.org/debian-security stable/updates InRelease
Hit:3 http://deb.debian.org/debian stable-updates InRelease
Hit:4 http://deb.debian.org/debian experimental InRelease
Hit:5 http://deb.debian.org/debian stable-backports InRelease
Reading package lists... Done
W: Conflicting distribution: http://deb.debian.org/debian stable-backports InRelease (expected stable-backports but got buster-backports)
# This is just a warning which states , 
# that the the  InRelease file of 
# the stable-backports is 
# currently buster-backports .