Debian

How to Use Dpkg Install

In Debian and its derivates like Ubuntu and Linux Mint, the dpkg package manager is used for managing the packages. Dpkg, which is installed by default on the Debian and its derivatives can be used to install, build, and remove .deb packages. In this article, you will learn how to use dpkg install in Ubuntu system.

We will cover the following:

  • View List of Installed Packages
  • Install .deb package using dpkg
  • Verify package installation using dpkg
  • Remove installed package using dpkg

We have performed the procedure mentioned in this article on the Ubuntu 20.04 system. Moreover, we have used the command line Terminal application for running the commands in Ubuntu. To open the Terminal, you can use the Ctrl+Alt+T keyboard shortcut.

Note that for installing the .deb package in your Ubuntu system, you must be root user or the normal user with sudo privileges.

View List of Installed Packages

Before installing a new package, you might want to list the installed packages on your system. To do so, use the dpkg command with –list or –l option as follows:

$ dpkg --list

It will show you a long list of installed packages on your system.

Install .deb Package Using Dpkg

Installing a .deb package using the dpkg command is quite simple. Simply type dpkg followed by –install or –i option and the .deb file name.

$ sudo dpkg --install [.deb file]

Make sure you run the above command from the same directory where the .deb package resides. Alternatively, if you are running the above command from some other directory, mention the full path to .deb file as follows:

$ sudo dpkg --install [path/to/.deb file]

Example:

$ sudo dpkg --install skypeforlinux-64.deb

The dpkg command installs the specified package only without any dependencies. In case, you are installing a package which requires some dependencies, you will receive an error like this:

dpkg: error processing package

Also, the dpkg will not install the package and will leave it in an unconfigurable and broken state.

To resolve this error, run the following command in Terminal:

$ sudo apt -f install

This command will fix the broken package and install the required dependencies assuming they are available in the system repository.

Verify Package Installation Using Dpkg

Although you can verify the package installation by searching it through the Ubuntu dash menu. If it is available there, that verifies the package is installed.

However, the dpkg also allows you to verify the package installation. Simply type dpkg with –status or –s option to verify the package installation:

$ dpkg --status [package-name]

Remove Installed Package Using Dpkg

Once you no longer need an installed package, you can remove it using the dpkg command. For removing an installed package, you will need to mention the installed package name instead of mentioning the .deb package name that was used to install the package.

To find out the exact package name, you can use the following command with any keyword related to the package name:

$ dpkg –l | grep keyword

In the case of Skype package, you can simply type skype:

$ dpkg –l | grep skype

Once you have found the exact name of the installed package, you can remove it using the following syntax using the –remove or –r option:

$ sudo dpkg --remove [package file]

Example:

$ sudo dpkg --remove skypeforlinux

You can see that instead of typing the “skypeforlinux-64.deb”, we have simply typed the Skype installed package name.

In this article, you have learned how to install a .deb package using the dpkg command in the Ubuntu 20.04 system. You have also learned how to view a list of installed packages, verify the package after installation, and remove a package when you no longer need it. I hope you liked the article!

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.