How To Install .deb Packages

Ubuntu Documentation

How To Install .deb Files
How To Install .deb Files.

Introduction

Every Linux distribution based on Debian will be using Debian packages as a method for installing and uninstalling the software.

Debian packages are identified by the file extension .deb and this guide will show you how to install and uninstall .deb files using graphical tools and the command line.

Why Would You Install A .deb File Manually?

Most of the time you will use a package manager such as the Ubuntu Software Centre, Synaptic or Muon to install the software within Debian based distributions.

 

If you prefer to use the command line you are likely to use apt-get.

Some applications aren't available in the repositories and have to be downloaded from the vendor's websites.

You should be careful about downloading and installing Debian packages from sources that do not exist in the distribution's repositories.

Some of the biggest applications are delivered in this format, including Google's Chrome web browser. For this reason, it is important to know how to install the packages manually.

Where To Get A .deb File (for demonstration purposes)

First of all, you will need to go and get a .deb file to install. 

Visit https://launchpad.net/ to see a list of some packages that you can install in .deb format. Remember this is just a guide to show how to install .deb packages and that you should really try and use the package managers first or if using a Ubuntu-based distribution find a relevant PPA.

The package I am going to show is QR Code Creator (https://launchpad.net/qr-code-creator). A QR code is one of those funny symbols you see everywhere from the back of Crisp packets to bus stop adverts. When you take an image of the QR Code and run it through the reader it will take you to a web page, almost like a hyperlink as a funny image.

On the QR Code Creator page, there is a .deb file. Clicking on the link downloads the .deb file to your downloads folder.

How To Install .deb Packages

The tool used to install and uninstall Debian packages is called dpkg. It is a command line tool and through the use of switches, you can do many different things.

The first thing you will want to do is install the package.

sudo dpkg -i <packagename>

For example to install the QR Code Creator the command would be as follows:

sudo dpkg -i qr-code-creator_1.0_all.deb

If you would prefer to (not sure why) you can also use --install instead of -i as follows:

sudo dpkg --install qr-code-creator_1.0_all.deb

What Is In A .deb File?

Have you ever wondered what makes up a .deb package? You can run the following command to extract the files from a package without installing it.

dpkg-deb -x qr-code-creator_1.0_all.deb ~/qrcodecreator

The above command extracts the contents of the qr-code-creator package into a folder called qrcodecreator located within the home folder (i.e. /home/qrcodecreator). The destination folder qrcodecreator must already exist.

In the case of qr code creator the contents are as follows:

  • usr
  • usr -> bin
  • usr -> bin -> qr-code-creator
  • usr -> share
  • usr -> share -> applications
  • usr -> share -> applications -> qr-code-creator.desktop
  • usr -> share -> doc
  • usr -> share -> doc -> qr-code-creator
  • usr -> share -> doc -> qr-code-creator -> changelog.gz
  • usr -> share -> doc -> qr-code-creator -> copyright
  • usr -> share -> man
  • usr -> share -> man -> man1
  • usr -> share -> man -> man1 -> qr-code-creator.1.gz
  • usr -> share -> pixmaps
  • usr -> share -> pixmaps -> qr-code-creator.png
  • usr -> share -> qr-code-creator

Removing .deb Packages

You can remove a Debian package using the following command:

sudo dpkg -r <packagename>

If you want to remove the configuration files as well you will need to use the following command:

sudo dpkg -P <packagename

Summary

If you are using a Ubuntu based distribution you can just double click on the .deb file and it will load into the Software Centre.

You can then just click install.