APT and aptitude

From SaruWiki
Revision as of 16:30, 5 August 2012 by Saruman! (talk | contribs) (added apt-file)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Using APT and Aptitude

Your Debian system can easily be expanded, and also kept up-to-date with the latest security fixes, if you use Debian's beautiful APT (Advanced Packaging Technology) tools. Of all available APT-based tools, we usually use the following:

  • apt-get, the command line utilities that go with APT; or
  • aptitude, a curses-based frontend for APT.

These APT-based tools are incredibly powerful and flexible, but we're not going to explain them fully here (for tuturials and whatnot, go here). What we need to establish now, is how to configure APT, and how to use it.

APT gets its information from a configuration file that can be found in /etc/apt. Of these, the most important is sources.list because it defines what packages and updates can be installed from where, and even what version of Debian we want to maintain. For now let's just suffice to say that in the sources.list, you need to remove the references to the CD-ROm with which you installed the system, and specify which on-line repository you wish to use for installing and updating packages. To this end, open /etc/apt/sources.list with your favourite text editor while you are logged in as root.

References to the CD-ROM look a bit like this:

deb cdrom:[Debian GNU/Linux testing _Etch_ - Official Beta i386 CD Binary-1 20070317-21:45]/ etch contrib main

Disable this line by putting a hash (#) in front of it (you could have more than one line beginning with deb cdrom:).

Now make sure you have a section that references one or more on-line repositories. This could make your sources.list look like this:

# deb cdrom:[Debian GNU/Linux testing _Etch_ - Official Beta i386 CD Binary-1 20070317-21:45]/ etch contrib main

deb ftp://ftp.nl.debian.org/debian/ etch main contrib
deb-src ftp://ftp.nl.debian.org/debian/ etch main contrib

deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib

# deb ftp://ftp.nl.debian.org/debian-volatile etch/volatile main contrib

When you want to update, change, add software, or even remove software, you better update your APT system by running one of the following commands:

  • sudo apt-get update
  • sudo aptitude update
  • sudo aptitude, then press u

Note: if you haven't installed sudo yet, then you can only run the commands as root, and they are then: apt-get update, aptitude update, and aptitude then u.

Getting informed on installed packages

You might at some time wonder if a package is already installed. Usually, you'd check this using

dpkg --get-selections

The output of this can be rather unwieldy, but you can send the output to a program like grep to refine your search. As an example: use

dpkg --get-selections | grep install -c

to see just how many packages you have.

But this standard command doesn't directly concerns itself with versions or installation history.

Now if you're wondering what version a specific package (or set of packages) is, then you can install package apt-show-versions and run it on the command line; if you wish to know the version of a particular file, e.g. sudo, you'd run

apt-show-versions sudo

This package is described on Debian Admin. It can do much more, but there's a fine man page for that.

Furthermore, if you're interested in the installation history of your packages, you could check out the dpkg log file, by default /var/log/dpkg.log. This logging file/location is set in /etc/dpkg/dpkg.cfg. So to find the installation time/date of all programs, you could execute

grep "status installed" /var/log/dpkg.log

Getting information on packages that are NOT installed

This can be done with a package named apt-file. More information here.