apt-get is the first front end — command-line based — which was developed within the project.
synaptic, aptitude (which includes both a text mode interface and a graphical one — even if not complete yet), wajig, etc. The most recommended interface, apt-get, is the one used during the installation of Debian, and the one that we will use in the examples given in this section. Note however that aptitude's command-line syntax is very similar. When there are major differences between apt-get and aptitude, these differences will be detailed.
apt-get update. Depending on the speed of your connection, the operation can take a while since it involves downloading a certain number of Packages/Sources/Translation-language-code files, which have gradually become bigger and bigger as Debian has developed (at least 10 MB of data for the main section). Of course, installing from a CD-ROM set does not require any downloading — in this case, the operation is very fast.
apt-get install package and apt-get remove package. In both cases, APT will automatically install the necessary dependencies or delete the packages which depend on the package that is being removed. The apt-get purge package command involves a complete uninstallation — the configuration files are also deleted.
sources.list mentions several distributions, it is possible to give the version of the package to install. A specific version number can be requested with apt-get install package=version, but indicating its distribution of origin (Stable, Testing or Unstable) — with apt-get install package/distribution — is usually preferred. With this command, it is possible to go back to an older version of a package (if for instance you know that it works well), provided that it is still available in one of the sources referenced by the sources.list file. Otherwise the snapshot.debian.org archive can come to the rescue (see sidebar GOING FURTHER Old package versions: snapshot.debian.org).
Example 6.3. Installation of the unstable version of spamassassin
#apt-get install spamassassin/unstable
apt-get upgrade or aptitude safe-upgrade (of course after apt-get update). This command looks for installed packages which can be upgraded without removing any packages. In other words, the goal is to ensure the least intrusive upgrade possible. apt-get is slightly more demanding than aptitude because it will refuse to install packages which were not installed beforehand.
apt-get will generally select the most recent version number (except for packages from Experimental and stable-backports, which are ignored by default whatever their version number). If you specified Testing or Unstable in your sources.list, apt-get upgrade will switch most of your Stable system to Testing or Unstable, which might not be what you intended.
apt-get to use a specific distribution when searching for upgraded packages, you need to use the -t or --target-release option, followed by the name of the distribution you want (for example: apt-get -t stable upgrade). To avoid specifying this option every time you use apt-get, you can add APT::Default-Release "stable"; in the file /etc/apt/apt.conf.d/local.
apt-get dist-upgrade (“distribution upgrade”). With this instruction, apt-get will complete the upgrade even if it has to remove some obsolete packages or install new dependencies. This is also the command used by users who work daily with the Debian Unstable release and follow its evolution day by day. It is so simple that it hardly needs explanation: APT's reputation is based on this great functionality.
aptitude full-upgrade is aptitude's corresponding command although dist-upgrade is also recognized (but deprecated).
/etc/apt/apt.conf.d/ directory. Remember for instance that it is possible for APT to tell dpkg to ignore file conflict errors by specifying DPkg::Options { "--force-overwrite"; }.
Acquire::http::proxy "http://yourproxy:3128". For an FTP proxy, write Acquire::ftp::proxy "ftp://yourproxy". To discover more configuration options, read the apt.conf(5) manual page with the man apt.conf command (for details on manual pages, see Section 7.1.1, “Manual Pages”).
-t command-line option or the APT::Default-Release configuration directive).
/etc/apt/preferences file with the names of the affected packages, their version, their origin and their new priority.
/etc/apt/preferences, it first takes into account the most specific entries (often those specifying the concerned package), then the more generic ones (including for example all the packages of a distribution). If several generic entries exist, the first match is used. The available selection criteria include the package's name and the source providing it. Every package source is identified by the information contained in a Release file that APT downloads together with the Packages files. It specifies the origin (usually “Debian” for the packages of official mirrors, but it can also be a person's or an organization's name for third-parties repositories). It also gives the name of the distribution (usually Stable, Testing, Unstable or Experimental for the standard distributions provided by Debian) together with its version (for example 5.0 for Debian Lenny). Let's have a look at its syntax through some realistic case studies of this mechanism.
/etc/apt/preferences file:
Package: * Pin: release a=stable Pin-Priority: 900 Package: * Pin: release o=Debian Pin-Priority: -10
a=stable defines the name of the selected distribution. o=Debian limits the scope to packages whose origin is “Debian”.
Package: perl Pin: version 5.14* Pin-Priority: 1001
man apt_preferences.
apt-get being such a marvelous tool, it is tempting to pick packages coming from other distributions. For example, after having installed a Stable system, you might want to try out a software package available in Testing or Unstable without diverging too much from the system's initial state.
apt-get manages such coexistence very well and limits risks very effectively. The best way to proceed is to list all distributions used in /etc/apt/sources.list (some people always put the three distributions, but remember that Unstable is reserved for experienced users) and to define your reference distribution with the APT::Default-Release parameter (see Section 6.2.3, “System Upgrade”).
sources.list file. In this case, you can use apt-get install package/testing to install a package from Testing. If the installation fails due to some unsatisfiable dependencies, let it solve those dependencies within Testing by adding the -t testing parameter. The same obviously applies to Unstable.
upgrade and dist-upgrade) are done within Stable except for packages already upgraded to another distribution: those will follow updates available in the other distributions. We'll explain this behavior with the help of the default priorities set by APT below. Do not hesitate to use apt-cache policy (see sidebar) to verify the given priorities.
/etc/apt/preferences has not been used to force priorities higher than 1000 for some packages).
/etc/apt/preferences to this effect:
Package: * Pin: release a=unstable Pin-Priority: 490
apt-get (which was initially specific to aptitude) is the tracking of packages installed only through dependencies. These packages are called “automatic”, and often include libraries for instance.
apt-get autoremove will get rid of those packages. aptitude does not have this command because it removes them automatically as soon as they are identified. Both programs include a clear message listing the affected packages.
apt-mark auto package will mark the given package as automatic whereas apt-mark manual package does the opposite. aptitude markauto and aptitude unmarkauto work in the same way although they offer more features for marking many packages at once (see Section 6.4.1, “aptitude”). The console-based interactive interface of aptitude also makes it easy to review the “automatic flag” on many packages.
aptitude why package (apt-get has no similar feature):
$ aptitude why python-debian
i aptitude Recommends apt-xapian-index
i A apt-xapian-index Depends python-debian (>= 0.1.15)