Install/Remove .deb package in Ubuntu/Debian

Ubuntu/Debian Linux distributions contains huge list of packages in their software repositories. Still, we may need to install other packages due to various reasons like dependency issues, third party packages etc. There are two options available to us for installing these other packages. These are – either we add them to repository or we download the .deb package file. In this article, we would discuss the ways to install and remove .deb package file manually.

Before downloading the .deb package file, we need to first check the processor architecture for our system. It would help us save a great deal of time, if we already know which package would be supported by our processor’s architecture. To do that, run the following command in terminal –

lscpu

It would return with two results, which are self-explanatory.

CPU op-mode(s): 32-bit, 64-bit – then its 64-bit Processor architecture. If its just – CPU op-mode(s): 32-bit – then its a 32-bit Processor architecture.

Know more, about i386 and amd64 architectures

Install using dpkg command

Then, download and save the supported package to a directory. Open terminal again, you need to have a super user access. If you don’t have one then contact your system administrator for assistance.

Move to the directory where you downloaded the package by using the change directory cd command.

cd /path/to/package

Then, we will make use of dpkg command to install the package. DPKG is an acronym for Debian Package Manager.

dpkg -i /path/to/package.deb

Next, there will be packages that may require additional packages to be installed. These additional packages are the dependencies without which our source package may/may not work. So, if it is required then we may need to pass the following command to the terminal.

apt install -f

If there was any error during package installation, that could be due to dependencies, then we need use the above command to fix the broken system.

Remove using dpkg command

For some reason, we may want to remove the package installed. We can do that with the help of dpkg command. But, first we need to know if the package which we are about to remove is installed on our system or not. To check, run the following command.

dpkg -l | grep <package-name>

There are two options available to us for removing a package – either we keep or remove configuration files of the packages already installed.

To keep configuration files, run the following. -r option is for removing the package.

dpkg -r <package-name>

Or, to remove the configuration files too, run the following in terminal. -P option is for purging the package.

dpkg -P <package-name>

Just to confirm if your package has been successfully removed, again run.

dpkg -l | grep <package-name>

In conclusion, we have discussed the ways to install or remove .deb package.

Similar Posts