Ubuntu and other Debian-based Linux distributions use .deb packages to distribute software. These packages contain all the files and metadata needed to install applications. Installing a .deb file can be done using various methods, both through the command line and graphical interfaces.

Method 1: Installing with apt Command

The apt command is a powerful package management tool that can handle dependencies automatically when installing .deb files.

  1. Open a terminal window.
  2. Navigate to the directory containing the .deb file using the cd command. For example:
cd ~/Downloads
  1. Install the .deb package using apt:
sudo apt install ./package_name.deb

Replace package_name.deb with the actual file name.

This command tells apt to install the local package and automatically resolves and installs any dependencies.


Method 2: Installing with GDebi Package Installer

GDebi is a lightweight tool specifically designed to install .deb files and handle dependencies.

Using GDebi via Command Line

  1. Install GDebi if it's not already installed:\
sudo apt install gdebi
  1. Navigate to the directory containing the .deb file:
cd ~/Downloads
  1. Install the package using GDebi:
sudo gdebi package_name.deb

Replace package_name.deb with the actual file name.

Using GDebi via Graphical Interface

  1. Install GDebi using the terminal:
sudo apt install gdebi
  1. Locate the .deb file in the file manager.
  2. Right-click the file and select Open with GDebi Package Installer.
  3. Click the Install Package button.

GDebi will handle dependencies and install the package.


Method 3: Installing with dpkg Command

The dpkg command is a low-level tool for installing and managing Debian packages. It does not resolve dependencies automatically, so additional steps may be required.

  1. Open a terminal window.
  2. Navigate to the directory containing the .deb file:
cd ~/Downloads
  1. Install the package using dpkg:
sudo dpkg -i package_name.deb

Replace package_name.deb with the actual file name.

  1. If there are missing dependencies, dpkg will display errors.
  2. Fix dependency issues by running:
sudo apt install -f 

This command tells apt to fix broken dependencies.


Method 4: Installing with Software Center

The Ubuntu Software Center provides a graphical way to install .deb files.

  1. Locate the .deb file in the file manager.
  2. Double-click the file to open it with Software Center.
  3. Click the Install button.

Software Center will install the package and handle dependencies automatically.


Uninstalling .deb Packages

To remove a package installed from a .deb file, you can use the following methods.

Using apt Command

  1. Open a terminal window.
  2. Remove the package using apt:
sudo apt remove package_name 

Replace package_name with the actual name of the package.

Using Software Center

  1. Open the Ubuntu Software Center.
  2. Click on the Installed tab.
  3. Locate the package and click the Remove button.

Installing .deb files on Ubuntu can be accomplished through various methods, each suited to different preferences. Using apt or GDebi ensures that dependencies are resolved automatically, providing a smooth installation experience.