Javatpoint Logo
Javatpoint Logo

Linux dpkg command

dpkg is software at the package management base within the free OS Debian and its several derivatives. This software is used for installing, removing, and providing details of .deb packages.

dpkg is a low-level mechanism. A higher level mechanism, i.e., APT is more widely used as compared to the dpkg tool because it can retrieve packages by remote locations and negotiate with typical package relations like dependency resolution.

APT (Advanced Package Tool) front ends such as synaptic (GTK) and aptitude (ncurse) can be used for the friendlier interfaces.

dpkg (Debian package) gives the dpkg program and various other programs essential for the run-time working of the packaging system such as dpkg-trigger, dpkg-divert, dpkg-statoverride, dpkg-query, dpkg-split, and dpkg-deb. Also, it includes many programs like start-stop-daemon and update-alternatives.

A program, i.e., install-info is used to be added, but later it was removed because now it is developed and shared separately. The dpkg-dev (Debian package) includes the large build tools.

In Debian, it is the Debian-based system and primary package management program. It is used for installing, building, removing, and managing several packages. For dpkg, aptitude is the main front end.

Following is the syntax of the dpkg command.

Syntax:

Brief History of dpkg

Originally, dpkg was developed by Ian Murdock as a Shell script in January 1994. Then, Carl Streeter, Ian Murdock, and Matt Welsh rewrote this software in Perl. After that, the main section was rewritten by Ian Jackson in C in 1994. The dpkg name was formerly "Debian package" shortening.

Development Tools of dpkg

These development tools of dpkg are listed and explained below:

  1. dpkg-dev include the development tool's series needed to unpack, create, and upload the source packages of Debian. These include:
  2. dpkg-source: It packs and unpacks a Debian package source files.
  3. dpkg-gencontrol: It reads the details through an unpacked tree source (Debian) and produces the binary package control package, making an entry for it in Debian/files.
  4. dpkg-shlibdeps: It calculates the run dependency for the libraries.
  5. dpkg-genchanges: It reads the details through the unpacked tree source (Debian) that once constructed makes a control file.
  6. dpkg-buildpackage: It can be defined as a control script that could automatically be used for constructing the package.
  7. dpkg-distaddfile: It includes the input of a file to Debian files.
  8. dpkg-parsechangelog: It reads the modifications file, i.e., a changelog of the unpacked tree source (Debian), and makes a prepared result conveniently with the details for those modifications.

Database of dpkg

The database of dpkg is located in the /var/lib/dpkg file. This "status" file includes the installed software list on our current system. Also, there are no details about repositories within this database.

Examples of dpkg

The mother OS (Debian Linux/GNU) of several Linux distributions like Mint, Ubuntu, Kali, Knoppix, etc. uses many package Manager such as dpkg-split, dpkg-deb, deselect, tasksel, synaptic, aptitude, apt, and dpkg.

We will specify all of these package managers before describing the dpkg command.

APT Command

It is short for Advanced Package Tool. It does not compromise with deb packages and directly works. However, it works with deb archive by a location described within a file, i.e., "/etc/apt/sources.list".

Aptitude

For Debian, aptitude can be defined as a package manager (text-based) which is a front end for 'apt'. It enables all users to easily manage packages.

Synaptic

It is a package manager (graphical) which makes it efficient for installing, upgrading, and uninstalling the package.

Tasksel

It enables all users for installing every corresponding package related to a particular task.

Deselect

It is a package management tool (menu-driven). Initially, it is used while the initial time install and substituted with aptitude now.

Dpkg-deb

It interacts with the archive of Debian.

Dpkg-split

It is helpful in merging and splitting huge files into small file chunks to be stored on smaller size media such as a floppy disk.

Install a package with the dpkg command

In Ubuntu, the most common use of this command is the installation of a package. In Debian or Ubuntu, we can install any deb package with the help of a command option, i.e., dpkg -i.

Here, how we could install the package:


Linux dpkg command

Use dpkg install

The package manager of dpkg is used to manage the packages in Debian and many derivatives such as Linux Mint and Ubuntu. By default, the dpkg package is installed on Debian and its derivatives could be used for installing, building, and removing .deb packages.

Installing .deb package with dpkg


Linux dpkg command

Ensure that we execute the above command through the similar directory in which the .deb package is residing. If we are alternatively executing the above command through any other directory, we need to specify the complete path to the .deb file below:


Linux dpkg command

The dpkg command can install only the specified package without the dependencies. If we are installing any package which needs a few dependencies, we will get an error. This error can look like below:

dpkg: error processing package

The dpkg will also not install a package and leave it in a broken and unconfigurable state.

In the terminal, we can execute the below command for resolving the above error:

This command revolves around the broken package and also installs the needs dependencies expecting they are existing in the repository of our system.

Deleting a Package

If we no longer require service or program on our computer, there is no requirement to use it. We will require to specify the name of the installed package to remove an installed package rather than specifying the name of the .deb package that was used for installing the package.

To search the package name, we can use the below command using a keyword corresponding to the name of the package:

We can simply use skype in case of a Skype package:


Linux dpkg command

Once we have detected the exact installed package name, we can uninstall or remove a service or program from our computer with the help of the --r or --remove option:


Linux dpkg command

Updating our repositories

The repositories of the dpkg command store every package that existed for installation on our Debian or Ubuntu Linux distribution.

Often, we can end up getting packages old versions for any program if new versions have been released already because these packages are locally stored. It causes a requirement for a way to update our repositories.

Another option, i.e., dpkg --update-avail has got us covered. It will analyze the repositories (online) and download each updated package to our local repository.

We will update the local repository to the recent version as follows:


Linux dpkg command

View installed packages list

We might wish to list all the installed packages on our system before installing any new package. For doing so, we can use this dpkg command using the --l or --list option below:


Linux dpkg command

It will display us an installed packages ling list on our system.

Verification of Package installation with dpkg

Although we can verify the installation of the package by searching it from the dash menu of Ubuntu. If it is present there, that will verify the package installation.

However, the dpkg command also permits us to verify the installation of the package. We can simply enter dpkg with --s or --status for verifying the package installation:


Linux dpkg command

Purge Package

We can purge the package. It will uninstall the software and remove each configuration file rather than leaving them behind its the help of the -P option.

The command is as follows:


Linux dpkg command

We can use the -s option for quickly checking whether the package is installed successfully or not.

The command is as follows:


Linux dpkg command

We can examine a .deb file's contents by appending the -c option.

The command is as follows:


Linux dpkg command

We can unpack the .deb file to manipulate and see its content with the help of the --unpack option.

The command is as follows:


Linux dpkg command

We can repackage everything within the .deb file with the help of the --configure option if we make alterations to .deb files (unpacked).

The command is as follows:


Linux dpkg command

Probably, we will need to opt for a command, i.e., dpkg-reconfigure if we want to configure the settings further if the package has been installed and constructed already.

The command is as follows:


Linux dpkg command





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA