Jump to content

LPI Linux Certification/Use Debian Package Management

From Wikibooks, open books for an open world

Detailed Objective

[edit | edit source]

(LPIC-1 Version 5.0

Weight: 3

Description:
Candidates should be able to perform package management using the Debian package tools.

Key knowledge areas:

  • Install, upgrade and uninstall Debian binary packages.
  • Find packages containing specific files or libraries which may or may not be installed.
  • Obtain package information like version, content, dependencies, package integrity and installation status (whether or not the package is installed).
  • Awareness of apt.

The following is a partial list of the used files, terms and utilities:

  • /etc/apt/sources.list
  • dpkg
  • dpkg-reconfigure
  • apt-get
  • apt-cache

Package Structure

[edit | edit source]

In order to understand how to use Debian's package management system, it would be useful to first have an understanding of how a Debian package is named. For example, the package ncftp_3.1.3-1_i386.deb has 5 major parts:

  • ncftp - the name of the program/application/library
  • 3.1.3 - the version of the program/application/library assigned by the original (upstream) author(s)
  • 1 - the revision number of the package assigned by the person(s) who packaged the program for a Debian system
  • i386 - the architecture the packaged program is designed to run on
  • .deb - signifies this is a Debian package

Note that there is special significance to the use of underscores(_) and hyphens(-); an underscore shall separate the name of the program and its version, a hyphen shall separate a version number and the revision number, and an underscore shall separate the revision number and the architecture.

dpkg is the "grandaddy" or "back-end" of the Debian Package Management System. Features present in the more advanced tools are not available to dpkg but it is nevertheless a useful tool.

Some notes:

  • dpkg keeps its record of available packages in /var/lib/dpkg/available.

Some of the more common functions used by administrators by dpkg are:

Adding, Removing, and Configuring Packages

  • dpkg {-i|--install} <package-name> will install the specified package
  • dpkg {-r|--remove} <package-name> will remove the specified package (but leave the configuration files intact)
  • dpkg {-P|--purge} <package-name> will remove the specified package and the corresponding configuration files
  • dpkg --root /target -i <package> will install a package into a unbootable system by specifying the system root.
  • dpkg --unpack <package-name> will unpack (but do not configure) a Debian archive into the file system of the hard disk
  • dpkg --configure <package-name> will configure a package that already has been unpacked

Querying Package Information

  • dpkg --info <package-name> will print out the control file (and other information) for a specified package
  • dpkg {-l|--list} this will give you a list of installed packages.
  • dpkg {-a|--pending} is given instead of a package name, then all packages unpacked, but marked to be removed or purged in file /var/lib/dpkg/status, are removed or purged, respectively.
  • dpkg -s (--status) <package-name> will give you a description of installed package

Updating Package Information

  • dpkg --update-avail <package-name> will replace old information with with new information from package.
  • dpkg --merge-avail <package-name> will combine old information with new information from package.

dpkg-reconfigure

[edit | edit source]

dpkg-reconfigure reconfigures packages after they have already been installed.

  • dpkg-reconfigure <package-name> to reconfigure the initial installation settings
  • dpkg-reconfigure --priority=medium package [...] will set the minimum priority of question that will be displayed
  • dpkg-reconfigure --all will reconfigure all packages
  • dpkg-reconfigure locales will generate any extra locales
  • dpkg-reconfigure --p=low xserver-xfree86 will reconfigure X server

Dselect

[edit | edit source]

The utility that allows you on Debian to easily add/remove packages is dselect.

  • Choose the access method to use.
  • Update the list of available packages, if possible.
  • Request which packages you want on your system.
  • Install and upgrade wanted packages.
  • Configure any packages that are unconfigured.
  • Remove unwanted software.

There is on dselect an interactive menu that will allow you to install/remove packages. Care must be taken with this utility. You can damage your system.

Dselect menu example:

Debian `dselect' package handling frontend.
0. [A]ccess    Choose the access method to use. 
1. [U]pdate    Update list of available packages, if possible. 
2. [S]elect    Request which packages you want on your system.
3. [I]nstall   Install and upgrade wanted packages. 
4. [C]onfig    Configure any packages that are unconfigured. 
5. [R]emove    Remove unwanted software.
6. [Q]uit      Quit dselect.
$ dselect - list of access methods
Abbrev.        Descriptio  cdrom          Install from a CD-ROM.
* multi_cd       Install from a CD-ROM set.
nfs            Install from an NFS server (not yet mounted).
multi_nfs      Install from an NFS server (using the CD-ROM set) (not yet mounted).
harddisk       Install from a hard disk partition (not yet mounted).
mounted        Install from a filesystem which is already mounted.
multi_mount    Install from a mounted partition with changing contents.
floppy         Install from a pile of floppy disks.
apt            APT Acquisition [file,http,ftp]

apt-get

[edit | edit source]

If you know the name of a package you want to install, use apt-get. You must configure the sources.list file. This same file is used when you choose the apt access method of dselect. The location is /etc/apt.

  • apt-get install <package-name> will search its database for the most recent version of this package and will retrieve and install it from the corresponding archive as specified in sources.list. In the event that this package depends on another APT will check the dependencies and install the needed packages.
    • apt-get install <package-name>=<version> will install a package at the version specified
    • apt-get install <package-name> -o DPkg::options::="--force-overwrite" installs a package ignoring "error processing ..., which is also in package ..." errors.
  • apt-get remove <package-name> will remove the specified package but keep its configuration files.
  • apt-get --purge remove <package-name> will remove the specified package and its configuration files.
  • apt-get -u install <package-name> will upgrade and install a specific package.
  • apt-get -u upgrade will upgrade packages within the same distribution packages except those which have been kept back because of broken dependencies or new dependencies.
  • apt-get -u dist-upgrade will upgrade an entire Debian system at once.

apt-file

[edit | edit source]
  • apt-file search <file-name> will search for a package which includes the specified file.
  • apt-file list <package-name> will list the contents of a package matching the pattern. This action is very close to the dpkg -S command except the package does not need to be installed or fetched.

Apt-cache

[edit | edit source]

To find the name of a package that you want to install use apt-cache. apt-cache main options are :

  • add - Add a package file to the source cache
  • showpkg - Show some general information for a single package
  • stats - Show some basic statistics
  • search - Search the package list for a regex pattern
  • show - Show a readable record for the package
  • depends – Show raw dependency information for a package
user@host:~$ apt-cache search gimp
babygimp - An icon editor in Perl-Tk
blackbook - GTK+ Address Book Applet
cupsys-driver-gimpprint - Gimp-Print printer drivers for CUPS
escputil - A maintenance utility for Epson Stylus printers
filmgimp - A motion picture editing and retouching tool

Resources

[edit | edit source]

APT HOWTO
http://www.debian.org/doc/manuals/apt-howto/index.en.html
dselect Documentation for Beginners
http://www.debian.org/doc/manuals/dselect-beginner/

Exercises

[edit | edit source]
  1. Install a system with Debian.
  2. Get familiar with dselect and remove the tcpdump utility.
  3. Install back with apt-get the package that contains the tcpdump utility.
  4. Try kpackage to install ethereal