Installing and Working with Packages in Ubuntu

In Ubuntu, much like any other OS, one needs software. The primary method of software installation is via the GUI Ubuntu Software tool. This, however, is neither the preferred nor the only way of installing packages. Beginners tend to stick to GUIs; however, as you spend more time on Ubuntu, you end up having to resort to existing repositories and adding repositories, and worse comes to worst, manually install the packages. In this tutorial, we will learn to install and work with packages in Ubuntu.

Method 1: Repositories

The best part about Ubuntu and any flavor of Linux is that it comes with its own repository. A repository is basically like a store filled with thousands of packages or software. However, all the software available in the repository is open source and for Linux.

You can, of course, search the repository for available packages using the apt command. To search the repository in Ubuntu:

sudo apt-cache search [what you’re looking for]

For example, suppose that I’m looking for a package called MySQL:

sudo apt-cache search MySQL

Suppose that you’ve found the package you want but are looking for more information about the found package, then you’d use the apt show command.

apt show [file to show]


apt  show mysql-client-8.0

Next, you can check for the dependencies using the following code:

apt depends [file to scan]


apt  depends mysql-client-8.0

Once you’re satisfied with the package you’ve found, you can install it. The apt-get install command will fetch and install the dependencies first and then install the package itself so that you can sit back and relax while the command does everything automatically for you. To install using the repository in Ubuntu:

sudo apt-get install [file you want to install]


sudo apt-get install mysql-client-8.0 -y

Once installed, it is always a possibility that you might not like the package and wish to completely remove it from your system. To remove an installed package, type:

sudo apt-get remove [your_package]


sudo apt-get remove mysql-client-8.0

Apt -get remove will not remove the configuration files of the program you installed, and in those cases, you may use purge instead. To remove everything, including configuration files, you would type:

sudo apt purge mysql-client-8.0

Method 2: Adding to a repository

There are many instances when and where the package you’re looking for will not be in the repository; however, it might be available in a totally different repository. So what do we do then? We add the repository that does have the file to our own. Apt primarily look for repositories in /etc/apt/sources.list – this is where all the repositories are found.

In order to add another repository to the ones you currently own, you can use the Personal Package Archives (PPAs). It is advised that you do not randomly add repositories, as it is not scanned for malware! Only add from trusted sources!

For example, if you want to add the ppa for the simple screen recorder:

sudo add-apt-repository ppa:maarten-baert/simplescreenrecordersudo apt-get update

To remove the ppa repository for the simple screen recorder:

sudo add-apt-repository --remove ppa:maarten-baert/simplescreenrecorder

For example, when you want to install Wine for Linux, they ask you to add a repository.


sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'

The latter will add the repository specified to /etc/apt/sources.list.

Method 3: Manually install the package

At times, there’s just no other way around it; you need to install the package manually. In such cases, the packaging format you get depends on the software you’re downloading.

DEB Packages
In order to install a DEB packaging, I personally use gdebi:

sudo apt-get install gdebi

Once gdebi is installed, you can use the following code to install the .deb package.

gdebi [your_package.deb]

Alternatively, most users use the dpkg command. The dpkg command is used to install, build, remove, and manage debian packages. Sometimes, you simply download a deb file and can’t use the apt command; in such cases, we use the dpkg command.

To install a package using dpkg:

sudo dpkg --install [your_package.deb]

One can also use dpkg to scan the deb file to see its contents:

sudo dpkg -c [your_package.deb]

To uninstall using dpkg, you need the package name used by the system; you can get it by typing:

sudo dpkg -l | grep [your package name -- guess]

And then uninstall it using the following:

sudo dpkg -r [package name]

And should it require reconfiguration because it’s corrupt, you can type:

sudo dpkg --configure [package name]

RPM Package
RPM packages are typically used by CentOS, RHEL, and Fedora. However, there are times when as an Ubuntu user, you just need to use an rpm package. You can turn the rpm package into a deb package and install it in such cases.

First, let’s install alien, a package used to convert rpm files into deb files.

sudo apt-get install alien

Then, download the rpm file and type:

sudo alien -d [your_package.rpm]

For example, the latter will create a deb version of the same package that you can install with gdebi.

gdebi [your_package.deb]

With tarballs, it’s harder to satisfy dependencies, and it’s harder to remove and update. However, there are times when tarballs are the only option, especially if you are prone to downloading off of github. In such cases, to install tarballs:

tar -xvzf package.tar.gz (or tar -xvjf package.tar.bz2)
cd package
sudo make install

Advanced Linux users prefer to install packages via the command line; this is a fact. Packages come in all shapes and forms; this is another fact. Some packages are rpm packages, others are tarballs, others can be found in a repository, and others require you to add novel repositories. In this tutorial, we learned the various ways in which one can install and manage packages. In fact, we rely on the apt and the dpkg commands to manage them overall. Using apt and dpkg, we can install, update, and remove packages.

Happy Coding!

About the author

Kalyani Rajalingham

I'm a linux and code lover.