A small APT-Guide Cookbook

What does APT mean?

APT is short for Advanced Packaging Tool and is a collection of programs and scripts that help both the sysadmin (in your case root) with the installation and management of deb-files but equally the system itself to know what is installed.

Sources List

The "APT" -system needs a config-file that contains information about the locations of the installable and upgradeable packages and is commonly referred to as a sources.list.

Sources are contained in a directory or folder named:
/etc/apt/sources.list.d/

Inside the folder are 2 files called:
/etc/apt/sources.list.d/debian.list and
/etc/apt/sources.list.d/sidux.list

This has the benefit of easier (automated) mirror switching, and makes it safer to replace lists.

You can also add your own /etc/apt/sources.list.d/*.list files

All sidux ISOs use the following sources as default:

#sidux
# Free University Berlin/ spline (Student Project LInux NEtwork), Germany
deb ftp://ftp.spline.de/pub/sidux/debian/ sid main fix.main
#deb-src ftp://ftp.spline.de/pub/sidux/debian/ sid main fix.main

Further entries for non-free needs can be found in our always updated sidux.list and debian.list:

#Debian
# Unstable
deb http://ftp.us.debian.org/debian/ unstable main contrib non-free
#deb-src http://ftp.us.debian.org/debian/ unstable main contrib non-free

# Testing
#deb http://ftp.us.debian.org/debian/ testing main contrib non-free
#deb-src http://ftp.us.debian.org/debian/ testing main contrib non-free

# Experimental
#deb http://ftp.us.debian.org/debian/ experimental main contrib non-free
#deb-src http://ftp.us.debian.org/debian/ experimental main contrib non-free

NOTE: In this example ftp.us indicates its using USA repositories.You may edit this file, as root, to use the repositories closest to you, simply by changing the country, that is, change ftp.us to ftp.nl, or ftp.uk. Most countries have local mirrors, thus bandwidth is conserved; speeds improved.

List of Debian Servers and mirrors current status.

To be able to obtain updated information on the packages APT uses a database. This database contains the packages but also which other packages are needed for that package to work (called dependencies). The program apt-get uses this database when installing your chosen packages to resolve all the dependencies and thereby to guarantee that the chosen packages will work. The updating of this database is done by the command apt-get update.

# apt-get update
	(which returns )
Get:1 http://sidux.com sid Release.gpg [189B]
Get:2 http://sidux.com sid Release.gpg [189B]
Get:3 http://sidux.com sid Release.gpg [189B]
Get:4 http://ftp.de.debian.org unstable Release.gpg [189B]
Get:5 http://sidux.com sid Release [34.1kB]
Get:6 http://ftp.de.debian.org unstable Release [79.6kB]

Installing a new package

Presuming the Apt-database is updated and the name of the package is known, then the following command will install a package called qemu, for example, and all its dependencies: (further on you will see how to search and find packages.)

# apt-get install qemu
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  bochsbios openhackware proll vgabios
Recommended packages:
  debootstrap vde
The following NEW packages will be installed:
  bochsbios openhackware proll qemu vgabios
0 upgraded, 5 newly installed, 0 to remove and 20 not upgraded.
Need to get 4152kB of archives.
After unpacking 11.9MB of additional disk space will be used.
Do you want to continue [Y/n]? n

Deleting a package

Similarly it should come as no surprise that the following will deinstall a package, however it will not remove the dependencies:

apt-get remove gaim
Reading package lists... Done
Building dependency tree... Done
The following packages will be REMOVED:
  gaim gaim-irchelper
0 upgraded, 0 newly installed, 2 to remove and 310 not upgraded.
Need to get 0B of archives.
After unpacking 4743kB disk space will be freed.
Do you want to continue [Y/n]?
(Reading database ... 174409 files and directories currently installed.)
Removing gaim-irchelper ...
Removing gaim ...

In this last case the configuration files of the package 'gaim' (basically how its setup) were not deleted from the system. You could use them when installing the same package again and it would work with these settings

If you want the config files deleted also, issue this command:

apt-get --purge remove gaim
Reading package lists... Done
Building dependency tree... Done
The following packages will be REMOVED:
  gaim*
0 upgraded, 0 newly installed, 1 to remove and 309 not upgraded.
Need to get 0B of archives.
After unpacking 4678kB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 174405 files and directories currently installed.)
Removing gaim ...
Purging configuration files for gaim ...

Note the * after the package name in the output of apt . The asterisk in the output of apt indicates that the configuration files will also be removed.

Hold and/or Downgrade a package

Sometimes it may be necessary to rollback to a previous version of a package or put it on hold, due to a major bug with the latest version you have just installed.

Hold

echo package hold|dpkg --set-selections

To take a package off Hold

echo package install|dpkg --set-selections

To list packages on hold:

dpkg --get-selections | grep hold

Downgrading

The steps are using kmahjongg as an example:

  1. enable/uncomment testing sources in /etc/apt/sources.list.d/debian.list 
    (delete the #) so that it reads
    deb http://ftp.nl.debian.org/debian/ testing main contrib non-free
  2. apt-get update
  3. apt-get install kmahjongg/testing 
  4. Put the newly installed package on hold with:
    echo kmahjongg hold|dpkg --set-selections
  5. comment the testing sources in /etc/apt/sources.list.d/debian.list 
  6. apt-get update

When you do want to get the latest version of the package just do this:

echo kmahjongg install|dpkg --set-selections
apt-get update
apt-get install kmahjongg

Upgrade of an Installed System - dist-upgrade - Overview

If the whole system is to be upgraded this is achieved through a dist-upgrade. You should always check Current Warnings on the sidux main web site, and check the warnings against the packages that your system wants to dist-upgrade. If you need to hold a package refer to Downgrade and Hold a package

An 'upgrade' only of 'debian sid' is not recommended.

Frequency of a dist-upgrade

dist-upgrade as routinely as you can, ideally once every week or two, at least 1 time per month to be safe. A dist-upgrade initiated only every 2 to 3 months should be considered the safe outer limit. For non-standard packages, or self compiled packages, you need to be much more careful with upgrading, since those may break your system at any time due to incompatibilities.

After the database is updated with apt-get update, one can find out which packages have new/newer versions: (first install apt-show-versions)

apt-show-versions -u
libpam-runtime/unstable upgradeable from 0.79-1 to 0.79-3
passwd/unstable upgradeable from 1:4.0.12-5 to 1:4.0.12-6
teclasat/unstable upgradeable from 0.7m02-1 to 0.7n01-1
libpam-modules/unstable upgradeable from 0.79-1 to 0.79-3.........

The update of a single package including its dependencies can for example (for gcc-4.0) be done with:

apt-get install gcc-4.0
Reading package lists... Done
Building dependency tree... Done
gcc-4.0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and xxx not upgraded

Just downloading

A little known and great option to do a check for what packages are in a dist-upgrade is the -d flag:

apt-get update && apt-get dist-upgrade -d

The -d allows you to download the dist-upgrade without installing it whilst in X from the konsole and allows you to do the dist-upgrade in init 3 at a later time. This also gives you the chance to check warnings against the list as it wisely gives you the option to proceed or abort like this:

apt-get dist-upgrade -d
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  elinks-data
The following packages have been kept back:
  git-core git-gui git-svn gitk icedove libmpich1.0ldbl
The following packages will be upgraded:
  alsa-base bsdutils ceni configure-ndiswrapper debhelper
  discover1-data elinks file fuse-utils gnucash.........
35 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 23.4MB of archives.
After this operation, 594kB of additional disk space will be used.
Do you want to continue [Y/n]?Y 

Y will download the upgraded packages without touching the installed system.

After the 'dist-upgrade -d' has downloaded, and wish to complete the dist-upgrade, immediately or at a later time, please follow these steps:

dist-upgrade - The Steps

NEVER EVER do a dist-upgrade nor upgrade whilst in X
Always check Current Warnings on the sidux main web site. The warnings are there for a reason due to the very nature of unstable (Debian sid), which also updates 4 times per day.
Log out of KDE.
Go to Textmode by doing Ctrl+Alt+F1
logon as root,
and then type:
init 3
apt-get update
apt-get dist-upgrade
apt-get clean
init 5 && exit
NEVER DIST-UPGRADE [or UPGRADE] with adept, synaptic or aptitude:

If you do not go to init 3, well tough for you, you have been warned!

The Reasons NOT to use anything else but apt-get for a dist-upgrade

Package managers like adept, aptitude, synaptic and kpackage are not always able to account for the huge amount of changes which happen in Sid (depedency changes, name changes, maintainer script changes, ...).

This is not the fault of the developers of those tools though, they write a excellent tools and fabulous for the debian stable branch, they are simply just not suitable for the very special needs of Debian Sid.

Use whatever you like to search for packages, but stick with apt-get for actually installing/removing/dist-upgrading.

Package managers like adept, aptitude, synaptic and kpackage are at the least, non-deterministic (for complex package selection), mix that with a quickly moving target like sid and even worse an external repository of questionable quality (we don't use or recommend those, but they're a reality on your user systems) and you will be courting disaster.

The other item to note is that all of these types of GUI package managers need to run in init 5, and/or, in X, and in doing a dist-upgrade in init 5 and/or X , (or even an 'upgrade' which is not recommended), you will end up damaging up your system beyond repair, maybe not today or tomorrow, however in time you will.

apt-get on the other hand strictly does what it is asked to do, if there is any breakage you can pinpoint and debug/ fix the cause, if apt-get wants to remove half of the system (due to library transitions) it's the admin's call (that means you) to have at least a serious look.

This is the reason why debian builds use apt-get, not the other package manager tools.

Searching for a package with apt-cache

Another very useful command in the APT-system is apt-cache; it searches the APT-Database and shows information on packages; e.g. a list of all packages, that contain or address "sidux" and "manual" is obtained by:

$ apt-cache search sidux manual
.......
sidux-manual-common - the official sidux manual - common files
sidux-manual-es - the official Spanish sidux manual
sidux-manual-de - the official German sidux manual
sidux-manual-el - the official Greek sidux manual
sidux-manual - the official sidux manual - all languages
sidux-manual-pt-br - the official Brazilian Portuguese sidux manual
sidux-manual-en - the official English sidux manual
sidux-manual-reader - sidux manual reader

If you want more information on a particular package, you can use:

$ apt-cache show sidux-manual-en
Package: sidux-manual-en
Priority: optional
Section: doc
Installed-Size: 1088
Maintainer: Kel Modderman <kel@otaku42.de>
Architecture: all
Source: sidux-manual
Version: 01.12.2007.06.03-1
Depends: sidux-manual-common
Filename: pool/main/s/sidux-manual/sidux-manual-en_01.12.2007.06.03-1_all.deb
Size: 391222
MD5sum: 60f2175c3c5709745a4b4256ccc3c49d
SHA1: e275a0b27628b6aa210a4ced48d3646b438e78b8
SHA256: 2792580c7a091521301064180a1d0d8901f0a4af407b90432b9f8d8b6b3603ca
Description: the official en sidux manual
 This manual is divided into common sections, for example, .......

All installable versions of the package (they depend on your sources.list) can be listed by typing:

$ apt-cache policy sidux-manual-bg
sidux-manual-bg:
  Installed: (none)
  Candidate: 01.92.2009.09.14-1
  Version table:
01.92.2009.09.14-1 0
        500 http://sidux.net sid/main Packages

A complete description of the APT-System can be found at APT-HOWTO

Debian Package Search GUI application

apt-get update
apt-get install packagesearch

When you first start Debian Package Search you need to adjust Packagesearch>Preferences to use apt-get.

Please do not use Packagesearch to install packages, use it only as a GUI search engine.

On initial use you may be prompted to install deborphan. Please use with care.

Search can be done by

  • pattern
  • tags (based on the debtags system, a new way of categorizing Debian packages)
  • files
  • installed status
  • orphaned packages

Additionally a lot of information about the packages is displayed, including the files belonging to them. Please read the Help>Contents for a full explanation on how to use the Debian Package Search GUI application. At the moment the GUI is in English only.

A complete description of the APT-System can be found at APT-HOWTO

Page last revised 28/01/2010 0145 UTC