As part of its operation, APT uses a file that lists the 'sources' from which
packages can be obtained. This file is /etc/apt/sources.list.
The entries in this file normally follow this format:
deb http://site.http.org/debian distribution section1 section2 section3
deb-src http://site.http.org/debian distribution section1 section2 section3
Of course, the above entries are fictitious and should not be used. The first
word on each line, deb or deb-src, indicates the type
of archive: whether it contains binary packages (deb), that is,
the pre-compiled packages that we normally use, or source packages
(deb-src), which are the original program sources plus the Debian
control file (.dsc) and the diff.gz containing the
changes needed for `debianizing' the program.
We usually find the following in the default Debian sources.list:
# See sources.list(5) for more information, especialy
# Remember that you can only use http, ftp or file URIs
# CDROMs are managed through the apt-cdrom tool.
deb http://http.us.debian.org/debian stable main contrib non-free
deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
deb http://security.debian.org stable/updates main contrib non-free
# Uncomment if you want the apt-get source function to work
#deb-src http://http.us.debian.org/debian stable main contrib non-free
#deb-src http://non-us.debian.org/debian-non-US stable non-US
These are the lines needed by a basic Debian install. The first
deb line points to the official archive, the second to the non-US
archive and the third to the archive of Debian security updates.
The two last lines are commented out (with a `#' in front), so apt-get will
ignore them. These are deb-src lines, that is, they point to
Debian source packages. If you often download program sources for testing or
recompiling, uncomment them.
The /etc/apt/sources.list file can contain several types of lines.
APT knows how to deal with archives of types http,
ftp, file (local files, e.g., a directory containing
a mounted ISO9660 filesystem) and ssh, that I know of.
2.2 How to use APT locally
Sometimes you have lots of packages .deb that you would like to use APT to
install so that the dependencies would be automaticaly solved.
To do that create a directory and put the .debs you want to index in it . For
So, inside the directory /root, create an empty file, with any name. That is
because an APT repository needs a file known as "override", it may be
empty, but it has to exist. One may use the following command to create this
Inside this file you may want to define some options to override the ones the
ones that come with the package. It looks like follows:
package priority section
package is the name of the package, priority is low, medium or high and section
is the section to which it belongs. It is enough to leave the file empty.
In the above line, file is the "override" file, the command generates
a file debs/Packages.gz that contains various informations about the packages,
which are used by APT. To use the packages, finally, add:
deb file:/root debs/
After that just use the APT commands as usual. You may also generate a sources
repository. To do that use the same procedure, but remember that you need to
have the files .orig.tar.gz, .dsc and
.diff.gz in the directory and you have to use Sources.gz instead
of Packages.gz. The program used is also different. It is
dpkg-scansources. The command line will look like this:
dpkg-scansources debs | gzip > debs/Sources.gz
Notice that dpkg-scansources doesn't need an "override"
file. The sources.list's line is:
deb-src file:/root debs/
2.3 Deciding which mirror is the best to include in the sources.list file: netselect, netselect-apt
A very frequent doubt, mainly among the newest users is: "which Debian
mirror to include in sources.list?". There are many ways to
decide which mirror. The experts probably have a script that measures the ping
time through the several mirrors. But there's a program that does this for us:
To install netselect, as usual:
apt-get install netselect
Executing it without parameters shows the help. Executing it with a
space-separated list of hosts (mirrors), it will return a score and one of the
hosts. This score takes in consideration the estimated ping time and the hops
(hosts by which a network query will pass by to reach the destination) number
and is inversely proportional to the estimated download speed (so, the lower,
the better). The returned host is the one that had the lowest score (the full
list of scores can be seen adding the -vv option). See this example:
This means that, from the mirrors included as parameters to netselect,
ftp.debian.org.br was the best, with an score of 365.
(Attention!! As it was done on my computer and the network topography is
extremely different depending on the contact point, this value is not
necessarily the right speed in other computers).
Beginning with the 0.3 version, netselect package includes the
netselect-apt script, which makes the process above automatic.
Just enter the distribution tree as parameter (the default is stable) and the
sources.list file will be generated with the best main and non-US
mirrors and will be saved under the current directory. The following example
generates a sources.list of the stable distribution:
bash$ ls sources.list
ls: sources.list: File or directory not found
bash$ netselect-apt stable
bash$ ls -l sources.list
Remember: the sources.list file is generated
under the current directory, and must be moved to the /etc/apt
If you'd rather use your CD-ROM for installing packages or updating your system
automatically with APT, you can put it in your sources.list. To
do so, you can use the apt-cdrom program like this:
with the Debian CD-ROM in the drive. It will mount the CD-ROM, and if it's a
valid Debian CD it will look for package information on the disk. If your
CD-ROM configuration is a little unusual, you can also use the following
-h - program help
-d directory - CD-ROM mount point
-r - Rename a recognized CD-ROM
-m - No mounting
-f - Fast mode, don't check package files
-a - Thorough scan mode
apt-cdrom -d /home/kov/mycdrom add
You can also identify a CD-ROM, without adding it to your list:
Note that this program only works if your CD-ROM is properly configured in your