2. Using APT to install packages

2.1. Assumptions

I use the POTATO (version 2.2) release of Debian in my discussion here. To see which version you've got, try

% uname -r

My system is version '2.2.17'.

The uname utility is available in the shellutils package:
# apt-get install shellutils

to get it, if you don't have it.

In addition, I use the tcsh command shell, just to be difficult.

Note that your system is BOUND to be different from mine -- type and amount of memory, drive sizes, peripheral gadgets -- so YMMV (your mileage may vary) wildly from mine. Even so, with luck it might prove useful nonetheless...

2.2. Setup -- apt-setup

This little gizmo sets up the configuration file for you:

# apt-setup

It asks you some questions and winds up configuring your /etc/apt/sources.list file. It tells apt where to get the packages from, when you request an update to your currently installed packages or when you ask to install packages you've never tried before.

If you don't have apt-setup on your potato (or later) Debian system, get the base-config package, which supplies it:

# apt-get install base-config

Of course, you can always set up apt's sources.list file by hand if you must. Check out
% man sources.list
to learn about the format of the 'sources.list' file, if you're the determined type. For a list of Debian mirrors to use there, try
http://www.debian.org/misc/README.mirrors" But if you're like me -- lazy -- you'll just run

# apt-setup
and be done with it.

2.3. Following a distribution

Keep in mind that Debian is a work-in-progress, meaning that as holes are found and bugs are killed in the stable distribution, a whole new world is developing on the UNSTABLE distribution. If you need something from 'unstable' go ahead and try it -- just don't gamble more than you can afford to lose, right? Venturing into UNSTABLE is fine if you don't mind being on the "front lines" so to speak. Most of us stick with the stable distribution, which has no new gizmos being created; only patches and fixes are added to the stable release. You might occasionally want to delve into UNSTABLE territory, for some new functionality that's not available in the stodgy, old, stable area. It's up to you, but don't expect a refund if something breaks -- it's called UNSTABLE for a reason!

Starting in 2001 a new distribution of Debian is available. It is called testing, and it covers the ground between stable and UNSTABLE. Testing is made of packages that have survived 14 days in unstable without breaking. Major life-threatening bugs are thus solved before making their way into testing. However, that also means that security upgrades are also at least 14 days behind schedule...

However if your version of apt supports it ( >= 0.5 ), there is a very easy way to follow multiple distributions, it is called pinning:

You must modify /etc/apt/preferences and add:
1 Package: *
2 Pin: release a=stable
3 Pin-Priority: 900
5 Package: *
6 Pin: release a=testing
7 Pin-Priority: -10
then you must add lines for both stable and testing to your /etc/apt/sources.list and do an apt-get update which will download the usual files twice, one for each distribution.

After this, you can use the -t option to choose which distribution you want to get packages from:
# apt-get -t testing install sgmltools2
The Pin-Priority fields ensure that unless you specifiy it manually, all packages will be taken from the stable distribution (of course, dependencies are always met, so you might have to download more than one package from testing)

If you're running a live server, where any uncertainty or instability would be a definite liability, definitely shy away from UNSTABLE or even testing unless you enjoy soothing the frazzled nerves of management, and their paying customers, and your spouse, who keeps asking why you're always looking for a new job.

2.4. Updating your system -- apt-get upgrade

So you've got your Debian system humming -- you don't need to let it fall behind! You can easily stay up-to-date with the latest security patches, any bug fixes and an occasional enhancement. That's the beauty of apt.

Once sources.list is set up and you're online, first
# apt-get update
to refresh the list of available packages -- if new things are available, that is how your Debian system will learn of it -- and then simply
# apt-get upgrade
which downloads, configures and then replaces any packages you've already got that have been tweaked. You'll probably want to do it periodically, to squash bugs and plug security holes.

" NOTE that the Debian gurus work like the dickens to see to it that your settings are not clobbered when you upgrade a package or two. You may have spent a month getting exim or inetd to hum your very own tune, and heaven help the miscreant who clobbers your settings, right? Sometimes there's enough of a difference between what you've been running (the old version) and the upgrade to be installed (the new version) that the old settings may not be usable by the new program; in this unusual case, apt informs you that your old settings are being saved, and in order for the new program to function the way you want it to, you'll have to migrate your settings by hand. But this is rare -- usually, your settings stay right where you put them and you'd hardly ever know anything had improved. "


All this happens without having to restart. (For Mac and Windows people -- imagine leaving your computer up for two MONTHS! It's awesome!)

2.5. Installing packages -- apt-get install

Once you're online, it's easy to install new packages you're interested in; simply do something like
# apt-get install vim traceroute mysql-server mysql-client
# apt-get install logcheck
to download, configure and install whichever packages you want. " Where does apt put all this stuff it downloads? The "cache" is located under /var/cache/apt/; there's a 'table-of-contents' file there called pkgcache.bin (and if you're set up to also get source-code packages, you'll also have srcpkgcache.bin) and the actual *.deb package files are in /var/cache/apt/archives/. "