dpkg command on Linux (package management)
The dpkg utility is responsible for managing packages on Debian systems.
The dpkg is the base command for manipulating Debian packages on systems based on this family of distributions. If you have pacotes.deb, it is the dpkg that allows the installation or analysis of your content.
But this program only has a partial view of Debian package management: it knows what is installed on the system, and whatever is entered on the command line, but it knows nothing about the other packages available.
So, if you need to manually download a “pacote.deb” to manipulate it with dpkg.
Also, dpkg will fail if a dependency is not met during a package installation. Tools like apt and aptitude, on the other hand, will create a list of dependencies to install everything in the way as automated as possible.
The dpkg stores the information of the packages installed mainly in the /var/lib/dpkg/available and /var/lib/dpkg/status files. These files contain the list of available packages and status, respectively.
According to the Debian Wiki, it is responsible for maintaining the packages on the system at a low level.
The most common options are:
- -E: This option does not rewrite an already installed package of the same version;
- -G: This option does not rewrite an already installed package, even if it is older;
- -R: Processes all packages found in a given directory recursively.
The most frequent actions are:
- -i package-name: Installs the package package-name. This process involves backing up old files that already exist on the system, unpacking, installing, and configuring. This action can also be referenced with —install package-name;
- -l search key: Lists package information containing the same search key in the name; -L packagename
- : Lists the files installed by the package-name package package package;
- —print-avail packagename: ‘Lists all available information about the packagename package in /var/lib/dpkg/evaluable;
- —purge packagename: Removes the entire package package-name;
- -r package-name: Removes all package files, except settings;
- -s
- packagename: Shows package status;
- -S file: Search for a file in installed packages; —unpack packagename: Unpacks a package but does not install; - —configure packagename: Configures an uninstalled package.
Examples:
Install the acct_6.3.5-32_i386.deb package.
Removes the ace-of-penguins_1.2-3_i386.deb package from the system completely.
Configures the abook_0.4.16-1_i386.deb package.
The dpkg can also be used to find out which package a particular file belongs to with the “-S” option (capital letters):
The dpkg “-s” (lowercase) option can be used to view information for a particular package:
Package: coreutils Essential: yes Status: install ok installed Priority: required Section: useful Installed Size: 15719 Maintainer: Michael Stone Architecture: amd64 Multi-Arch: Foreign Version: 8.30-3 Pre-Depends: libacl1 (>= 2.2.23), libattr1 (>= 1:2 .4.44), libc6 (>= 2.28), libselinux1 (>= 2.1.13) Description: GNU core utilities This package contains the basic file, shell and text manipulation utilities which are expected to exist on every operating system.
dpkg -l | grep Mozilla
ii mozilla-browse 0.9.6-7 Mozilla Web Browser
$ dpkg —unpack man-db_2.8.5-2_amd64.deb
This command is not used much in practice, since the apt or apt-get commands are much easier to use.
Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.