Learning Debian GNU/LinuxBy Bill McCarty1st Edition September 1999 1-56592-705-2, Order Number: 7052 360 pages, $34.95 , Includes CD-ROM |
C.3 Using dpkg
You might think that dpkg has been superseded by the more recent package management tools, dselect and apt-get, which stress ease of use. However, dpkg remains a good choice for performing several common package management tasks.
C.3.1 Installing a Package
If you have a package file containing a package you want to install, the simplest way to install the package is to use the dpkg command:
dpkg --install packagefilewhere
packagefile
stands for the name of the package file, which generally ends with the characters .deb. If all the prerequisite packages have already been installed and if the package does not conflict with any installed packages, the command will unpack the package files, move them to their proper locations, and execute the scripts necessary to configure the package.If your system lacks a prerequisite package or if the specified package conflicts with a package installed on your system, dpkg will report the error and terminate. If the problem is the lack of one or more prerequisite packages, you can obtain and install them, and then install the desired package. If the problem is a package conflict, you must decide which of the conflicting packages you want. If you decide to remove an installed package, you can do so using the technique described in the following subsection.
C.3.2 Removing a Package
To remove an installed package, use the command
dpkg --remove packageThis command does not remove package configuration files, which may facilitate subsequent re-installation of the package. If you want to remove the configuration files as well, use the command:
dpkg --purge packageC.3.3 Querying the Package Database
The Debian package management facility maintains a database that contains information about installed packages. You can use the dpkg command to query this database.
C.3.3.1 Printing the description of a package
To print the description of a package, issue the following command:
dpkg --print-avail packagewhere
package
specifies the name of the package. For example, to print the description of the package gnome-guile, issue the command:dpkg --print-avail gnome-guileC.3.3.2 List packages by name
To list known packages by name, issue the following command:
dpkg -l patternwhere
pattern
is a single-quoted string that specifies a pattern. Only packages with names matching the pattern will be listed. The pattern can include wildcards characters such as an asterisk (*), which substitutes for any string of characters. For example, the pattern'apache*'
matches package names beginning with apache.The listing presents the following information:
- Selection status
Indicates the selection status established using dselect, which may be any one of:
- Status
Indicates the installation status of the package, which may be any one of:
- Not installed
- Installed
- Config-files
Indicates that only the package's configuration files are currently installed.
- Unpacked
Indicates that the package has been unpacked, in preparation for installation.
- Failed-config
Indicates that the package has been installed, but its configuration script failed.
- Half-installed
- Error
Indicates the error status of the package, which may be one or more of:
- Name
Gives the name of the package.
- Version
Gives the version number of the package.
- Description
Gives a brief description of the package. Descriptions are generally available only for installed packages.
If the command produces too much output to conveniently view, pipe its result through the more command, which lets you page through the output:
dpkg -l pattern | moreIf you want to view only installed packages, issue a command such as:
dpkg -l pattern | grep '^i' | moreFor example, to view installed packages with names beginning with gnome, issue the following command:
dpkg -l 'gnome*' | grep '^i' | moreThe pattern
'*'
matches any package name, so the following command prints information about every installed package:dpkg -l '*' | grep '^i' | moreC.3.3.3 Report status of a package
To report the status of a package, issue the following command:
dpkg --status packagewhere
package
specifies the name of the package.For example, to report the status of the gnome-guile package, issue the command:
dpkg --status gnome-guileC.3.3.4 List files installed from a package
To list the files installed from a specified package, issue the command:
dpkg --listfiles packagewhere
package
specifies the name of the package.For example, to list the files installed from the gnome-guile package, issue the command:
dpkg --listfiles gnome-guile
Back to: Learning Debian GNU/Linux
© 2001, O'Reilly & Associates, Inc.