In Linux, there are a lot of different distributions and each of these distributions has a different package type. For example .rpm or Red hat Package Manager is used as the package in the Linux distribution. A package is the compressed version of the software. In this article, we will go through the Debian package which is used by Ubuntu. D package or Debian Package is used to install and download the software in Debian based Linux systems. Debian files end with .deb extension.
Working with Debian Packages using dpkg Command
1. Installing a stand-alone package using the Debian package
To install a package -i flag is used. To download a stand-alone package using the Debian package, this command is used:
sudo dpkg -i name_of_package.deb
Example: To download standalone package for the open-source text editor, atom
sudo dpkg -i atom-amd64.deb

2. Removing a package using the Debian package
To remove a package -r flag is used
sudo dpkg -r name_of_package
Example: To remove the package for the text editor “atom”
sudo dpkg -r atom

Note: -P flag helps to remove everything including conf files.
dpkg -P [package-name]
dpkg -P googler_3.3.0-1_all.deb
3. Listing the debian packages
To list all the Debian packages -l flag is used.
dpkg -l
The above line would give the output similar to the one shown below:

To find a particular package use the grep command:
dpkg -l | grep name_of_package.
The output of this command would look similar to the one shown below:

4. List the dpkg commands available
-help option lists all the available dpkg commands
dpkg –help
Output of this command would look similar to the one shown below:


5. View the content of a particular package
To view the content of the particular package -c flag is used
dpkg -c [name of the package]
dpkg -c flashplugin-nonfree_3.2_i386.deb
Output of this command would look similar to the one shown below:

6. Print architecture of dpkg installs
–print-architecture command prints the architecture of dpkg installs
dpkg --print-architecture
Output could be amd64, i386, etc.
For example, the output produced by the above code is as shown:

7. Unpack a package
–unpack flag helps us unpack the package.
dpkg --unpack [package-name]
dpkg --unpack flashplugin-nonfree_3.2_i386.deb
The output would look as shown below:

The package can be later configured using –configure flag.
dpkg --configure [package-name]
dpkg --configure flashplugin-nonfree

8. Check if the package is installed or not
To check if a particular package is installed or not -s flag is used.
dpkg -s [package-name]
dpkg -s git
The output would look as shown below:

9. Reconfigure the installed package
To reconfigure the already installed package dpkg-reconfigure command is used
dpkg-reconfigure [package-name]
Locate the installed package
The location of the installed package can be found using -L flag.
dpkg -L [package-name]
dpkg -L git
The output would look as shown below:

10. Check for any issue with the installed package
–audit flag would be used to check for the issues with the package.
dpkg --audit
11. Erase information
–clear-avail – Erases available information about the current packages
dpkg –-clear-avail
12. Display dpkg version
dpkg –version is used to display dpkg version information.
sudo dpkg --version
