The software that you run on your PC is what makes it truly personal. It tells a lot about what you work with, what you like to do, or your hobbies.

This guide takes a look at how to manage software packages using the Debian Package Manager (dpkg) on Debian-based Linux distros like Ubuntu, Debian, Mint, and Kali, etc. Debian software packages have the .deb extension.

Software management is one of the most common tasks that you will do on your personal computer or as a system administrator.

What Is Dpkg?

Dpkg is a low-level utility that is comprised of a set of commands that are used in installing, removing, listing, and management of software packages on Debian-based Linux distros.

The dpkg utility is the foundation on which other software management tools such as, Apt and Synaptic are built on. These are categorized as high-level software management tools.

Installing Debian (.deb) Software Package files locally on your PC is one of the specialties of dpkg.

This is particularly important for installing software on machines that are off-grid for security purposes or due to network connectivity issues. Notable software packages that can be installed with dpkg include VS Code, Google Chrome, and VirtualBox just to mention a few.

Listing Installed Software Packages

To see a list of installed software packages on your computer, simply run the following command.

        dpkg --get-selections
    

The --get-selections command option shows installed package names in a simple and clean format.

To display available version details about installed packages, you can use the following command. In addition, information such as the software version, installed size, origin, priority, etc is listed.

        dpkg --print-avail
    

If you want to display software package information in a tabular form. You can use the dpkg-query command as follows.

        dpkg-query --list
    

Installing Software Packages

Installing software packages is one of the most common tasks we carry out on our PCs. Before you can install software packages on your computer with dpkg you first need to download the software package and have it locally. You can easily download software packages using your browser or via tools such as wget or curl.

You will need elevated privileges to install and remove software packages with dpkg.

For example to install Google Chrome, download it to the Downloads folder. Then simply run the following command.

        sudo dpkg --install ~/Downloads/google-chrome-stable_current_amd64.deb
    

Restoring Dependencies

Software packages in Linux often depend on other pieces of software to work smoothly.

When you install packages via dpkg it is often wise to restore dependencies with Apt using the following command just to make sure that everything works fine.

        sudo apt install -f
    

Tip: You can use a shorthand method for most dpkg commands. For example, dpkg -i package_name instead of dpkg --install package_name for installing software packages. This guide uses the latter approach because the long commands are more self-explanatory.

Related: How to Find and Fix Broken Packages on Linux

Updating Software

Keeping your system up to date is a good line of defense from security flaws and is key to having a more stable and robust system.

To update software packages installed via dpkg, you first have to download the newer package and then install it via the install command discussed in the section above.

To check for broken packages use the  -- audit option. This command option checks if all packages have been installed correctly and if there are any missing dependencies. Should there be a broken package, then the dpkg utility will give you advice on suggested fixes.

        dpkg --audit
    

Re-Configuring a Software Package

Another powerful option that dpkg provides is the ability to reconfigure a software package that has already been installed. For example, to reconfigure VirtualBox you can run the command below and you will be presented with a configuration screen.

        sudo dpkg-reconfigure virtualbox-6.1
    

Dpkg software reconfiguration screen

Removing Software Packages

When you no longer need a piece of software and are ready to remove it, or you want to remove it to upgrade the software then you can use the --remove command option.

        sudo dpkg --remove google-chrome-stable
    

(In the command above, google-chrome-stable is the package name)

When you remove software packages using the --remove option the configuration files that are associated with the package you are removing remain intact. So the next time you re-install that piece of software it will use the previous configurations.

To totally remove a software package and its associated configurations, you can use the --purge option.

        sudo dpkg --purge google-chrome-stable
    

Getting Information About a Software Package

You can get more information about the package you are about to install with --info.

        sudo dpkg --info ~/Downloads/google-chrome-stable_current_amd64.deb
    

The output includes information such as the software architecture, the maintainer, and version number, etc.

Dpkg utility software pckage information output

Inspecting Software Package Content

You can also inspect the contents of a Debian package using --contents. The listing will outline the directory structure of the package and all important files such as the software license and other manifest files.

        dpkg --contents ~/Downloads/google-chrome-stable_current_amd64.deb
    

The package content is displayed in a long listing format as below.

dpkg package contents

Finding Out If a Package Is Installed

You can easily check if some software package has been installed on your machine using the --status option. For example, to find out if zoom has been installed on your system, simply run the command below.

        sudo dpkg --status zoom
    

The output also displays other details such as the purpose of the software package and the vendor.

A sample output looks as below. For example, line two of the command output shows the status of the package. As you can see from the output, the zoom package is installed on this particular machine.

Dpkg utility software packge status

You can search for package directories that satisfy the conditions of free distribution according to Debian standards from their official site.

Read More: Basic Commands to Get You Started With Linux

Getting Help

To learn more about the dpkg command you can use the --help option.

        dpkg --help
    

For more detailed information about the dpkg command options and the state of software packages use the Man Pages.

        man dpkg
    

What About Alternative Package Managers?

dpkg is a powerful utility for installing and managing software packages. Higher-level tools such as apt and synaptic use dpkg. Other alternatives for installing packages include Apt, Synaptic, and Aptitude.