The way we install application programs in Linux is a little different than in Windows. In Windows, you generally download the .exe files and execute them by just double-clicking them to install the application program. Like these .exe files, we have .deb packages in Debian-based Linux distributions like Ubuntu.
Today we are specifically talking about them and how to install deb files in Ubuntu. There are not any prerequisites required for this tutorial. You don't have to be a Linux pro for installing a deb package as we are going to show both the ways i.e. 1) The Terminal approach and 2) The GUI approach.
Install Deb File from Command Line
The Linux command line is a very powerful interface and can be used to control every service and tool on your Linux desktop.
1. Using dpkg command
dpkg command is a command line tool to deal with .deb packages to install, build, remove and manage packages by passing specific parameters.
Let's start with the installation procedure. Assuming that you already have a .deb package file of some application. You can generally find these files on the downloads page of the application or software. So, open up the terminal window and let's begin.
For example, I want to install Sublime Text editor on my Ubuntu machine so I will either get the Debian package from their website or just use the terminal window to fetch the file using the wget command like the below :
First I will navigate to the Downloads folder :
Then fetch the file :
You can skip the above steps if you already have the deb package and move ahead in the tutorial.
Before installing, let's just get some information about the package that we are going to install.
Syntax: -I give all the information of the deb package like dependencies, installation size, etc.
dpkg -I /path/to/file.deb
You can either specify the full path of the file or just change your directory where the file is present.
For example, I am already in the Downloads folder, so let's just print all the info :
dpkg -I sublime-text_build-3211_amd64.deb
You can also list down all the files that the deb is going to install :
dpkg -c sublime-text_build-3211_amd64.deb
As you can see, it also shows the path where all the files are going to be copied.
It's time to install the deb package using the dpkg command.
sudo dpkg -i /path/to/package/file.deb
For example, in my case it will be :
sudo dpkg -i sublime-text_build-3211_amd64.deb
It will take time depending on the package size. Mine was pretty fast. But before actually using the installed application let's check if there aren't any broken packages :
sudo apt-get check
Mine seems fine but it may not be the same for you guys, therefore to be on the safer side let's just run the following command to install all the missing dependencies that are required by the application :
sudo apt install -f
Mine doesn't show any installation of additional packages as it was already satisfied. Now you have successfully installed your favorite application.
2. Using apt
You may have used the apt command to update or install any package from the official Ubuntu repositories on your system. But did you know you can actually use it for installing deb packages? Yes, and I personally prefer apt over any other command line method because it automatically installs all the required dependencies and avoids any broken dependencies problem.
Using apt to install deb file is quite simple
sudo apt install ./packagename.deb
See, it's that simple. For example, I am again going to install sublime on my system and see how :
sudo apt install ./sublime-text_build-3211_amd64.deb
Don't forget to put the (./) before the name of the deb files as it tells the apt command that we are dealing with a local file and installing nothing from the official repositories. If you are not in the current directory give the full path of the deb package but don't forget the (./).
3. Using gdebi
gdebi package installer is another great tool to install deb files in your Ubuntu system. This tool solves any dependency problems occurring with previous methods. It also shows you any package conflicts. Gdebi package installer can be used both ways - Terminal and GUI.
But before we will need to install it as it is not present by default -
sudo apt install gdebi
The Terminal Approach :
The general syntax to follow is :
sudo gdebi /path/to/package/file.deb
But you can explore more options with the following command :
I am installing sublime text using gdebi inside my terminal :
sudo gdebi sublime-text_build-3211_amd64.deb
It will prompt you to install or not hit "y" and it will automatically install deb files with all the dependencies.
The GUI Approach
Gdebi also has its gtk application which is super easy to use. To launch the GUI app just hit the below in the terminal :
It will pop up a window through which you can select your favourite deb packages
Just open your files from Files > Open.
You can directly run the gdebi GUI installer in the current directory by passing the file name as well.
In my case it will be as below :
Now you need to only click the install button.
Tired of using the terminal again and again? Don't worry just go to your file using any file manager installed on your system like nautilus, etc. Just right-click on the deb file and choose Open With > Gdebi Package Installer
4. Using Software Center
Next is the easiest and the most recommended method to install deb packages on Ubuntu i.e. The Ubuntu Software Center. It is used to install various open-source applications like discord, owncloud, etc. It is the default software center and if you just double-click any deb files you will see it opens in the software center.
If any other application opens when you double-click we have to make sure that software install is selected. Right-click on the deb file and Open With > Software Install.
You will be presented with a below-like window. Just click the install button to install your favorite application.
You can see on the top right corner - Source: Local file(deb).
5. Using eddy
Eddy is another great GUI application to install, update, uninstall and view information about deb packages. It is designed, developed & maintained, especially for elementary OS. But with a few extra tweaks we can make it work on our Ubuntu Linux. Just follow the below instructions.
Power up your terminal and start hitting the following commands one by one :
sudo apt install valac libgranite-dev libpackagekit-glib2-dev libunity-dev meson ninja-build libzeitgeist-2.0-dev gettext git git clone https://github.com/donadigo/eddy.git cd eddy meson build && cd build meson configure -Dprefix=/usr ninja sudo ninja install com.github.donadigo.eddy
You have successfully installed Eddy on your system.
Now navigate to your deb package using any file manager. And right-click and Open With > Eddy.
It will open up a GUI with which you can install deb files.
Uninstall deb files
You have successfully installed the deb package but what about removing it from your system? Below we will see some easy ways to remove packages from your Ubuntu system.
1) Using the dpkg command
sudo dpkg -r package_name
I don't want sublime text now so I will remove the package using the following :
sudo dpkg -r sublime-text
If you are willing to remove all the configuration files too then use the below command :
sudo dpkg --purge package_name
sudo dpkg --purge sublime-text
2) Using the apt command
sudo apt remove package_name
sudo apt remove sublime-text
To remove all the config files :
sudo apt --purge remove package_name
3) Using the gdebi package manager
Again open the deb package using the gdebi manager. And click just click uninstall to get rid of the application.
4) Using Ubuntu Software Center
5) Using Eddy
Now you know 5 ways to install deb files on Ubuntu Linux. There may be other tools as well but these are the top 5 best tools that you should use. Personally, I prefer the GUI approach to the command line and do not worry about package conflicts/dependencies. You can choose the method that feels cooler to you!
Related Read: deb-get – How to Easily Install Third-Party Software on Ubuntu