So, you are trying to follow a tutorial from the web and installing a software using apt-get command and it throws you the unable to locate package error:
E: Unable to locate package xyz
You are surprised because the package should be available. You search on the internet and come across a solution that you have to enable universe or multiverse repository to install that package.
You can enable universe and multiverse repositories in Ubuntu using the commands below:
sudo add-apt-repository universe sudo add-apt-repository multiverse sudo apt update
You installed the universe and multiverse repository but do you know what are these repositories? How do they play a role in installing packages? Why are there several repositories?
I’ll explain all these questions in detail here.
The concept of repositories in Ubuntu
Okay, so you already know that to install software in Ubuntu, you can use the apt command. This is the same APT package manager that Ubuntu Software Center utilizes underneath. So all the software (except Snap packages) that you see in the Software Center are basically from APT.
Have you ever wondered where does the apt program install the programs from? How does it know which packages are available and which are not?
Apt basically works on the repository. A repository is nothing but a server that contains a set of software. Ubuntu provides a set of repositories so that you won’t have to search on the internet for the installation file of various software of your need. This centralized way of providing software is one of the main strong points of using Linux.
The APT package manager gets the repository information from the /etc/apt/sources.list file and files listed in /etc/apt/sources.list.d directory. Repository information is usually in the following format:
deb http://us.archive.ubuntu.com/ubuntu/ bionic main
In fact, you can go to the above server address and see how the repository is structured.
When you update Ubuntu using the apt update command, the apt package manager gets the information about the available packages (and their version info) from the repositories and stores them in local cache. You can see this in /var/lib/apt/lists directory.
Keeping this information locally speeds up the search process because you don’t have to go through the network and search the database of available packages just to check if a certain package is available or not.
Now you know how repositories play an important role, let’s see why there are several repositories provided by Ubuntu.
Ubuntu Repositories: Main, Universe, Multiverse, Restricted and Partner
Software in Ubuntu repository are divided into five categories: main, universe, multiverse, restricted and partner.
Why Ubuntu does that? Why not put all the software into one single repository? To answer this question, let’s see what are these repositories:
When you install Ubuntu, this is the repository enabled by default. The main repository consists of only FOSS (free and open source software) that can be distributed freely without any restrictions.
Software in this repository are fully supported by the Ubuntu developers. This is what Ubuntu will provide with security updates until your system reaches end of life.
This repository also consists free and open source software but Ubuntu doesn’t guarantee of regular security updates to software in this category.
Software in this category are packaged and maintained by the community. The Universe repository has a vast amount of open source software and thus it enables you to have access to a huge number of software via apt package manager.
Multiverse contains the software that is not FOSS. Due to licensing and legal issues, Ubuntu cannot enable this repository by default and cannot provide fixes and updates.
It’s up to you to decide if you want to use the Multiverse repository and check if you have the right to use the software.
Ubuntu tries to provide only free and open source software but that’s not always possible specially when it comes to supporting hardware.
The restricted repositories consist of proprietary drivers.
This repository consists of proprietary software packaged by Ubuntu for their partners. Earlier, Ubuntu used to provide Skype through this repository. This repository is going to be discontinued in the futire versions of Ubuntu as it moves towards snap packaging.
Third party repositories and PPA (Not provided by Ubuntu)
The above five repositories are provided by Ubuntu. You can also add third-party repositories (it’s up to you if you want to do it) to access more software or to access newer version of a software (as Ubuntu might provide old version of the same software).
For example, if you add the repository provided by VirtualBox, you can get the latest version of VirtualBox. It will add a new entry in your sources.list.
You can also install additional application using PPA (Personal Package Archive). I have written about what is PPA and how it works in detail so please read that article.
Try NOT adding anything other than Ubuntu’s repositories in your sources.list file. You should keep this file in pristine condition because if you mess it up, you won’t be able to update your system or (sometimes) even install new packages.
Add universe, multiverse and other repositories
As of now, you should have the main, and universe repositories enabled by default. But, if you want to enable additional repositories through the terminal, here are the commands to do that:
To enable Universe repository, use:
sudo add-apt-repository universe
To enable Restricted repository, use:
sudo add-apt-repository restricted
To enable Multiverse repository, use this command:
sudo add-apt-repository multiverse
You must use sudo apt update command after adding the repository so that your system creates the local cache with package information.
If you want to remove a repository, simply add -r like sudo add-apt-repository -r universe.
Graphically, go to Software & Updates and you can enable the repositories here:
You’ll find the option to enable the partner repository in the Other Software tab.
To disable a repository, simply uncheck the box.
Bonus Tip: How to know which repository a package belongs to?
Ubuntu has a dedicated website that provides you with information about all the packages available in the Ubuntu archive. Go to Ubuntu Packages website.
You can search for a package name in the search field. You can select if you are looking for a particular Ubuntu release or a particular repository. I prefer using ‘any’ option in both fields.
It will show you all the matching packages, Ubuntu releases and the repository information.
As you can see above the package tor is available in the Universe repository for various Ubuntu releases.
I hope this article helped you in understanding the concept of repositories in Ubuntu.
If you have any questions or suggestions, please feel free to leave a comment below. If you liked the article, please share it on social media sites like Reddit and Hacker News.