The packaging system uses a private database to keep track of which packages
are installed, which are not installed and which are available for
installation. The apt-get program uses this database to find out
how to install packages requested by the user and to find out which additional
packages are needed in order for a selected package to work properly.
To update this list, you would use the command apt-get update.
This command looks for the package lists in the archives found in
/etc/apt/sources.list; see The /etc/apt/sources.list file, Section
2.1 for more information about this file.
It's a good idea to run this command regularly to keep yourself and your system
informed about possible package updates, particularly security updates.
3.2 Installing packages
Finally, the process you've all been waiting for! With your sources.list ready
and your list of available packages up to date, all you have to do is run
apt-get to get your desired package installed. For example, you
can run:
apt-get install xchat
APT will search it's database for the most recent version of this package and
will retrieve it from the corresponding archive as specified in
sources.list. In the event that this package depends on another
-- as is the case here -- APT will check the dependencies and install the
needed packages. See this example:
[root]@[/] # apt-get install nautilus
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
bonobo libmedusa0 libnautilus0
The following NEW packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
0 packages upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 8329kB of archives. After unpacking 17.2MB will be used.
Do you want to continue? [Y/n]
The package nautilus depends on the shared libraries cited,
therefore APT will get them from the archive. If you had specified the names
of these libraries on the apt-get command line, APT would not have
asked if you wanted to continue; it would automatically accept that you wanted
to install all of those packages.
This means that APT only asks for confirmation when it needs to install
packages which weren't specified on the command line.
The following options to apt-get may be useful:
-h This help text.
-d Download only - do NOT install or unpack archives
-f Attempt to continue if the integrity check fails
-s No-act. Perform ordering simulation
-y Assume Yes to all queries and do not prompt
-u Show a list of upgraded packages as well
Multiple packages may be selected for installation in one line. Files
downloaded from the network are placed in the directory
/var/cache/apt/archives for later installation.
You can specify packages to be removed on the same command line, as well. Just
put a '-' immediately after the name of the package to be removed, like this:
[root]@[/] # apt-get install nautilus gnome-panel-
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
bonobo libmedusa0 libnautilus0
The following packages will be REMOVED:
gnome-applets gnome-panel gnome-panel-data gnome-session
The following NEW packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
Need to get 8329kB of archives. After unpacking 2594kB will be used.
Do you want to continue? [Y/n]
If you somehow damage an installed package, or simply want the files of a
package to be reinstalled with the same version, you can use the
--reinstall option like so:
[root]@[/] # apt-get --reinstall install gdm
Reading Package Lists... Done
Building Dependency Tree... Done
0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 1 not upgraded.
Need to get 0B/182kB of archives. After unpacking 0B will be used.
Do you want to continue? [Y/n]
The version of APT used in the creation of this manual is version 0.5.3, which
was the current version in Debian `unstable' (sid) at the time of
writing. If you have this version installed, you have additional functionality
at your disposal: you can use a command of the form apt-get install
package/distribution to install a package from a specific distribution,
or apt-get install package=version. For example:
apt-get install nautilus/unstable
will install nautilus from the `unstable' distribution even if you are running
`stable'. The accepted values for 'distribution' are stable,
testing, and unstable.
You may prefer to use the -t switch to select a target
distribution, leading apt-get to favor that distribution when
resolving dependencies.
IMPORTANT: the `unstable' version of Debian is the version to which
the newest versions of Debian packages are uploaded first. This distribution
sees all of the changes that packages go through, both small ones and more
drastic ones which affect many packages or the whole system. For this reason,
this version of the distribution should not be used by inexperienced
users or by those who need proven stability.
The `testing' distribution is a little better than `unstable' with regards to
stability, but for production systems one should use the stable distribution.
3.3 Removing packages
If you no longer want to use a package, you can remove it from your system
using APT. To do this just type: apt-get remove package. For
example:
[root]@[/] # apt-get remove gnome-panel
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
gnome-applets gnome-panel gnome-panel-data gnome-session
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
Need to get 0B of archives. After unpacking 14.6MB will be freed.
Do you want to continue? [Y/n]
As you can see in the above example, APT also takes care of removing packages
which depend on the package you have asked to remove. There is no way to
remove a package using APT without also removing those packages that depend on
it.
Running apt-get as above will cause the packages to be removed but
their configuration files, if any, will remain intact on the system. For a
complete removal of the package, run:
[root]@[/] # apt-get --purge remove gnome-panel
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
Need to get 0B of archives. After unpacking 14.6MB will be freed.
Do you want to continue? [Y/n]
Note the '*' after the names. This indicates that the configuration files for
each of these packages will also be removed.
Just as in the case of the install method, you can use a symbol
with remove to invert the meaning for a particular package. In
the case of removing, if you add a '+' right after the package
name, the package will be installed instead of being removed.
[root]@[/] # apt-get --purge remove gnome-panel nautilus+
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
The following packages will be REMOVED:
gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
The following NEW packages will be installed:
bonobo libmedusa0 libnautilus0 nautilus
0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
Need to get 8329kB of archives. After unpacking 2594kB will be used.
Do you want to continue? [Y/n]
Note that apt-get lists the extra packages which will be installed
(that is, the packages whose installation is needed for the proper functioning
of the package whose installation has been requested), those which will be
removed, and those which will be installed (including the extra packages
again).
3.4 Upgrading packages
Package upgrades are a great success of the APT system. They can be achieved
with a single command: apt-get upgrade. You can use this command
to upgrade packages within the same distribution, as well as to upgrade to a
new distribution, although for the latter the command apt-get
dist-upgrade is preferred; see section Upgrading to a new release, Section
3.5 for more details.
It's useful to run this command with the -u option. This option
causes APT to show the complete list of packages which will be upgraded.
Without it, you'll be upgrading blindly. APT will download the latest versions
of each package and will install them in the proper order. It's important to
always run apt-get update before you try this. See section Updating the list of available packages,
Section 3.1. Look at this example:
[root]@[/] # apt-get -u upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages have been kept back
cpp gcc lilo
The following packages will be upgraded
adduser ae apt autoconf debhelper dpkg-dev esound esound-common ftp indent
ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0 libesd0-dev
libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev liborbit0
libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit procps psmisc
29 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 5055B/5055kB of archives. After unpacking 1161kB will be used.
Do you want to continue? [Y/n]
The process is very simple. Note that in the first few lines,
apt-get says that some packages were kept back. This
means that there are new versions of these packages which will not be installed
for some reason. Possible reasons are broken dependencies (a package on which
it depends doesn't have a version available for download) or new dependencies
(the package has come to depend on new packages since the last version).
There's no clean solution for this first case. For the second case, it's
sufficient to run apt-get install for the specific package in
question, as this will download the dependencies. An even cleaner solution is
to use dist-upgrade. See section Upgrading to a new release, Section
3.5.
3.5 Upgrading to a new release
This feature of APT allows you to upgrade an entire Debian system at once,
either through the the Internet or from a new CD (purchased or downloaded as an
ISO image).
It is also used when changes are made to the relationships between installed
packages. With apt-get upgrade, these packages would be kept
untouched (kept back).
For example, suppose that you're using revision 0 of the stable version of
Debian and you buy a CD with revision 3. You can use APT to upgrade your
system from this new CD. To do this, use apt-cdrom (see section
Adding a CD-ROM to the sources.list file,
Section 2.4) to add the CD to your /etc/apt/sources.list and
run apt-get dist-upgrade.
It's important to note that APT always looks for the most recent versions of
packages. Therefore, if your /etc/apt/sources.list were to list
an archive that had a more recent version of a package than the version on the
CD, APT would download the package from there.
In the example shown in section Upgrading
packages, Section 3.4, we saw that some packages were kept
back. We'll solve this problem now with the dist-upgrade
method:
[root]@[/] # apt-get -u dist-upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
Calculating Upgrade... Done
The following NEW packages will be installed:
cpp-2.95 cron exim gcc-2.95 libident libopenldap-runtime libopenldap1
libpcre2 logrotate mailx
The following packages have been kept back
lilo
The following packages will be upgraded
adduser ae apt autoconf cpp debhelper dpkg-dev esound esound-common ftp gcc
indent ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0
libesd0-dev libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev
liborbit0 libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit
procps psmisc
31 packages upgraded, 10 newly installed, 0 to remove and 1 not upgraded.
Need to get 0B/7098kB of archives. After unpacking 3118kB will be used.
Do you want to continue? [Y/n]
Note now that the packages will be upgraded, and new packages will also be
installed (the new dependencies of the packages). Note too that lilo is still
being kept back. It probably has a more serious problem than a
new dependency. We can find out by running:
[root]@[/] # apt-get -u install lilo
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
logrotate mailx
The following packages will be REMOVED:
debconf-tiny
The following NEW packages will be installed:
cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
logrotate mailx
The following packages will be upgraded
lilo
1 packages upgraded, 9 newly installed, 1 to remove and 31 not upgraded.
Need to get 225kB/1179kB of archives. After unpacking 2659kB will be used.
Do you want to continue? [Y/n]
As noted in the above, lilo has a new conflict with the package
debconf-tiny, which means it couldn't be installed (or upgraded)
without removing debconf-tiny.
3.6 Using APT with dselect
dselect is a program that helps users select Debian packages for
installation. It's considered somewhat complicated and rather boring, but with
practice you can get the hang of its console-based ncurses interface.
One feature of dselect is that it knows how to make use of the capacity Debian
packages have for "recommending" and "suggesting" other
packages for installation. To use the program, run `dselect' as
root. Choose 'apt' as your access method. This isn't truly necessary, but if
you're not using a CD ROM and you want to download packages from the Internet,
it's the best way to use dselect.
To gain a better understanding of dselect's usage, read the dselect
documentation found on the Debian page http://www.debian.org/doc/ddp.
After making your selections with dselect, use:
apt-get -u dselect-upgrade
as in the example below:
[root]@[/] # apt-get -u dselect-upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
lbxproxy
The following NEW packages will be installed:
bonobo console-tools-libs cpp-3.0 enscript expat fingerd gcc-3.0
gcc-3.0-base icepref klogd libdigest-md5-perl libfnlib0 libft-perl
libgc5-dev libgcc300 libhtml-clean-perl libltdl0-dev libsasl-modules
libstdc++3.0 metamail nethack proftpd-doc psfontmgr python-newt talk tidy
util-linux-locales vacation xbill xplanet-images
The following packages will be upgraded
debian-policy
1 packages upgraded, 30 newly installed, 1 to remove and 0 not upgraded.
Need to get 7140kB of archives. After unpacking 16.3MB will be used.
Do you want to continue? [Y/n]
Compare with what we see when running apt-get dist-upgrade on the same system:
[root]@[/] # apt-get -u dist-upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
Calculating Upgrade... Done
The following packages will be upgraded
debian-policy
1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 421kB of archives. After unpacking 25.6kB will be freed.
Do you want to continue? [Y/n]
Note that many of the packages from above are being installed because other
packages "suggested" or "recommended" them. Others are
being installed or removed (in the case of lbxproxy, for example) per the
choices we made while navigating through dselect's package listing. Dselect
can be a powerful tool when used in conjunction with APT.
3.7 How to keep a mixed system
People often use the testing distribution because it is more stable than
unstable and more up-to-date than stable. However, users who would like to run
the latest versions of some packages but still rather not trust their entire
systems to unstable also have the option of running mixed testing/unstable
systems. On the flip side, more conservative users may wish to run mixed
stable/testing systems.
To do that, put the following line on /etc/apt/apt.conf:
APT::Default-Release "testing";
Then, when going to install packages from unstable, just use the
-t switch:
# apt-get -t unstable install packagename
3.8 How to upgrade packages from specific versions of Debian
apt-show-versions provides a safe way for users of mixed
distributions to upgrade their systems without getting more of the less-stable
distribution than they had in mind. For instance, it is possible to upgrade
just your unstable packages by running:
3.9 How to keep specific versions of packages installed (complex)
You may have occasion to modify something in a package and don't have time or
don't want to port those changes to a new version of the program. Or, for
instance, you may have just upgraded your Debian distribution to 3.0, but want
to continue with the version of a certain package from Debian 2.2. You can
"pin" the version you have installed so that it will not be upgraded.
Using this resource is simple. You just need to edit the file
/etc/apt/preferences.
For example, to keep package sylpheed that I have modified to use
"reply-to-list" at version 0.4.99, I add:
Package: sylpheed
Pin: version 0.4.99*
Note that I used an * (asterisk). This is a "wildcard";
it say that I want that this "pin" to be valid for all versions
beginning with 0.4.99. This is because Debian versions its packages with a
"Debian revision" and I don't want to avoid the installation of these
revisions. So, for instance, versions 0.4.99-1 and 0.4.99-10 will be installed
as soon as they are made available. Note that if you modified the package you
won't want to do things this way.
The Pin-Priority field is optional; if not specified, it defaults
to 989.
Let's take a look at how pin priorities work. A priority lower than 0
indicates that the package should never be installed. Priorities 0 to 100
denote packages that are not installed and that have no available versions.
These won't come into the version-choosing process. Priority 100 is the
priority assigned to an installed package - for the installed version of a
package to be replaced by a different version, the replacement must have a
priority greater than 100.
Priorities above 100 indicate that a package should be installed. Typically,
the installed version of a package is changed only to upgrade it to a newer
version. Any priority between 100 and 1000 (inclusive) indicates this typical
behavior. A package with such a priority will not downgrade to an available
version with a lower version number. For instance, if I have sylpheed 0.5.3
installed and define a pin on sylpheed 0.4.99 with priority 999, package 0.4.99
will not be installed to satisfy the pin. To make a package
"downgradable", to satisfy the pin, it needs possess a priority
greater than 1000.
This concept of downgrading can have powerful applications; suppose that you
just upgraded your stable version of Debian to the
testing one but wanted to retract that decision - perhaps
testing just wasn't "tested" enough to suit you. You
can define a default pin, using a wildcard for the package name, to come back
to stable. For example:
After that, a apt-get -u dist-upgrade will downgrade your system
to the stable version.
A pin can be specified on a package's version,
release or origin.
Pinning on a version, as we have seen, supports literal version
numbers as well as wildcards to specify several versions at one time.
Option release depends on the Release file from an APT repository
or from a CD. This option may be of no use at all if you're using package
repositories that don't provide this file. You may see the contents of the
Release files that you have on /var/lib/apt/lists/. The paramters
for a release are: a (archive), c (components),
v (version), o (origin) and l (label).
In this example, we chose version 2.2* of Debian (which can be 2.2r2, 2.2r3 --
this accomodates "point releases" that typically include security
fixes and other very important updates), the stable repository,
section main (as opposed to contrib or
non-free) and origin and label Debian. Origin (o=) defines who
produced that Release file, the label (l=) defines the name of the
distribution: Debian for Debian itself and Progeny for Progeny, for example. A
sample Release file: