How to install and remove deb packages in Ubuntu

Created: Sat 18 Nov 2023 Updated: 8 months, 1 week ago

article-featured-image

In this article you will learn about how to install and remove deb packages in Ubuntu Linux. In Linux, when it comes to installing or removing a package, there are multiple ways, both in GUI and CLI. I'm using Ubuntu 20.04 in this tutorial but the same method can be applied on all other versions of Ubuntu. The same CLI methods can also be applied to other Debian-based distributions as well.

Prerequisite

We'll try to install Google Chrome in newly install Ubuntu Desktop. Download the Google Chrome deb package from the official Google page or you can use the below command to download the latest version of Google Chrome from the google mirror.

$
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

Above command will download the google-chrome-stable_current_amd64.deb package in your current directory. Now we'll use different methods to install this package.

Remember that in order to install a new package or remove an existing one, you'll need sudo privileges.

Installing deb package using GUI method

Ubuntu desktop comes with a GUI utility tool that allows users to install and remove deb packages. To install deb package using this method:

  • Navigate to the directory where deb file is downloaded.
  • Right click on deb file and select Open With Software Install option. open deb package with software manager
  • Software manager will open. Click on Install button to install to start the installation process. For larger pacakge, this process might take some time. installing deb package with software manager
  • Your current user or any other user in the current system must have sudo privileges. Installing a new package or removing an existing one requires privilege escalation where you will be prompted to input the current user password or sudo user password if the current user does not have sudo privileges.

Installing deb package using dpkg package manager

dpkg is a CLI package manager in Debian-based distributions that is used to manage deb packages. To install deb package using dpkg package manager, use the below command:

$
sudo dpkg -i ~/Downloads/google-chrome-stable_current_amd64.deb

Sudo privileges are required to install deb package using dpkg. Replace ~/Downloads/google-chrome-stable_current_amd64.deb with the path of your deb file. Installing deb package using dpkg will produce the same output as below image:

installing deb package using dpkg

Installing deb package using apt package manager

apt is the default command line-based package manager in Debian distributions. Instead of using dpkg, you can also use apt package manager to install deb package. Use the below command:

$
sudo apt install ~/Downloads/google-chrome-stable_current_amd64.deb

Just like other methods, sudo privilege is required to install the package using apt package manager. Replace ~/Downloads/google-chrome-stable_current_amd64.deb with the path of your deb file. Installing deb package using apt will produce the same output as below image:

installing deb package using apt

Methods to remove deb package

Now when it comes to removing a deb package, the same package managers and GUI methods can be used. Just remember that removing a deb package also requires sudo privileges.

Removing deb package using GUI method

To remove the deb package using GUI method, follow the below steps:
  • Navigate to the directory where deb file is located.
  • Right click on deb file and select Open With Software Install option.
  • Software manager will open. Click on bin icon to remove the package from the system. installing deb package with software manager
You will be prompted to input your user password. After the process, deb package will be removed from the system.

Removing deb package using dpkg

Using dpkg gives you more control on removing deb packages. Before running the remove command, make sure to grab the exact name of the package installed in the system. Use the below command to get the correct package name:

$
sudo dpkg --list|grep chrome

This command will list the google chrome package that I installed earlier. The purpose of this command is to get the exact name of the installed package. Replace chrome with your deb package name. It will produce the below output:

listing deb package using dpkg manager

Now i know that google-chrome-stable is the exact name of google chrome package installed in the system. Run the below command to remove this package:

$
sudo dpkg -r google-chrome-stable

This command will remove the Google Chrome package from the system but preserve It's configuration files.

Purge deb package using dpkg

If you want to completely remove the deb along with all It's configuration files, use this command:

$
sudo dpkg -P google-chrome-stable

In this command, option -P is used to specify that all the files related to this package should be removed. In other words, specified package will be purged from the system.

Removing deb package using apt

As you know by now apt is CLI based default package manager, which means you must know the exact name of the package you need to remove. You can use the below command for this purpose:

$
sudo apt list --installed|grep chrome

In this command, I'm trying to find the name of google chrome package through the list of installed packages in the system using apt tool.

listing deb package using apt manager After getting the exact package name that you need to remove, execute the below command:
$
sudo apt remove google-chrome-stable

This command will remove the Google Chrome deb package from the system but preserve It's configuration files.

Purge deb package using apt

To completely purge the installed deb package from the system, run the below apt command:

$
sudo apt purge google-chrome-stable

Purging a package from the system is often necessary when it comes to messed-up configuration files. After purging the package, make sure to check that the packages' configuration files in /etc are also removed. If not, remove them manually for a fresh and clean installation.

Conclusion

This tutorial was focused of google chrome deb package but the same principle and methods are applicable on all other deb packages. Keep in mind that installing any new package or removing/purging an existing installed package requires sudo privilege. So your user must be in the sudo group to perform these operations.

Suggested Posts:
LINUX post image
Install Latest Version of PHP on CentOS 8 and 7


CentOS is great. I have to admit that all those SELinux enforcement and other …

WINDOWS post image
Run any program as service in windows

Running a program as a service in Windows can be incredibly useful, allowing you to …

SCRIPTS post image
Create your own personal Secure VPN on the Cloud

This article is about creating a secure personal VPN. Nowadays with all those privacy …

LINUX post image
Create bootable USB drive from ISO image on Linux & Windows

This article is about creating a bootable USB drive from an ISO image. Below …

LINUX post image
Get Free valid SSL Certificate from Trusted CA

SSL plays a key role when it comes to your website security and encrypted …

Sign up or Login to post comment.

Sign up Login

Comments (0)