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.
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 packagefile
where 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.
To remove an installed package, use the command
dpkg --remove package
This 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 package
The Debian package management facility maintains a database that contains information about installed packages. You can use the dpkg command to query this database.
To print the description of a package, issue the following command:
dpkg --print-avail package
where 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-guile
To list known packages by name, issue the following command:
dpkg -l pattern
where 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:
Indicates the selection status established using dselect, which may be any one of:
Indicates the installation status of the package, which may be any one of:
Indicates that only the package’s configuration files are currently installed.
Indicates that the package has been unpacked, in preparation for installation.
Indicates that the package has been installed, but its configuration script failed.
Indicates the error status of the package, which may be one or more of:
Gives the name of the package.
Gives the version number of the package.
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 | more
If you want to view only installed packages, issue a command such as:
dpkg -l pattern | grep '^i' | more
For example, to view installed packages with names beginning with gnome, issue the following command:
dpkg -l 'gnome*' | grep '^i' | more
The pattern '*'
matches any package name, so
the following command prints information about every installed
package:
dpkg -l '*' | grep '^i' | more
18.222.114.28