In Linux, dpkg command is a powerful tool for managing packages on Debian-based Linux distributions like Debian itself, Ubuntu, and Linux Mint.
dpkg is used for installing, configuring, and removing software packages. In this guide, we will walk you through the process of installing the
dpkg command on your Linux system.
What is dpkg?
dpkg or Debian Package is the low-level package management tool for Debian-based systems that allows us to install, upgrade, configure, and remove software packages.
But to note that it doesn’t resolve package dependencies like more high-level package managers such as
yum, but it is required for working with individual package .deb files directly.
Installing dpkg on Debian-based Systems
Follow these quick steps to install dpkg very easily:
1. Open a Terminal: First open the terminal by pressing
Ctrl + Alt + T or by searching for “Terminal” in the system’s applications.
2. Update Package Lists: Make sure to update the package lists before installing any new software to ensure you are going to install the latest version of
dpkg. Run the following command to update:
sudo apt update
You may need to enter your password to authorize and proceed the installation.
3. Install dpkg: Once the package lists are updated, install dpkg by running the following command:
sudo apt install dpkg
It will download and install
dpkg or any other required dependencies. Thereafter confirm by typing “Y” when prompted.
4. Verify the Installation: After the installation is complete, we can verify that
dpkg is installed by checking its version:
Thats It! You’ve successfully installed
dpkg on your Debian-based Linux system.
How to Use dpkg?
After installation is completed, let’s see how to use dpkg:
Install a package
To install a package using
dpkg, we need to use the following command, replacing
<package-name> with the name of the
.deb package file:
sudo dpkg -i <package-name>.deb
Remove a package
To remove a package installed via
sudo dpkg -r <package-name>
List installed packages
To list all installed packages, you can use:
This will display a long list of installed packages, so you may want to pipe the output to a pager like
less for more comfortable viewing:
dpkg -l | less
Search for a package
To search for a package, use:
dpkg -l | grep <package-name>
In the above tutorial, we discussed what dpkg command is and how we can install it. We discussed how to use it and various operations like installing configuring removing or search packages.