What are Ubuntu Repositories? How to enable or disable them?

This detailed article tells you about various repositories like universe, multiverse in Ubuntu and how to enable or disable them.

So, you are trying to follow a tutorial from the web and installing a software using apt-get command and it throws you an 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

The concept of repositories in Ubuntu

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:

Main

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.

Universe

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

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.

Restricted

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.

Partner

This repository consists of proprietary software packaged by Ubuntu for their partners. Earlier, Ubuntu used to provide Skype through this repository.

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.

Tip

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:

Add repositories in Ubuntu
Adding Universe, Restricted and Multiverse repositories

You’ll find the option to enable the partner repository in the Other Software tab.

Add partner repository in Ubuntu
Adding Partner repository

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.

Search packages in Ubuntu

It will show you all the matching packages, Ubuntu releases and the repository information.

Searching packages in Ubuntu

As you can see above the package tor is available in the Universe repository for various Ubuntu releases.

Conclusion

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.

Similar Posts

  • Ubuntu server 20.04 seems to enable universe and multiverse by default. I can’t find where this is documented by Ubuntu.

  • Thanks a lot, this helped me understand why only specific version of the package is available to install. One question – is it possible and recommended to force different version of the package to install such as 20.4 focal has pgbouncer 1.12, however I am interested in installing pgbouncer 1.15(latest) but on same OS 20.4 focal?

    • You may install newer versions from additional repositories like a PPA. You may also get deb file for newer version, if the developer provides it. You can use snap as well.

      • thnx Abhishek, I was actually wondering why not ubuntu repo has latest version of package(pgbouncer in this case), is it because latest version has not been tested on that OS! There has to be some reason there is diferen versions of the package available for different version of OS.

  • I have created my own local repo using apache2 on ubuntu 16.04 after following steps in tutorial. But when I do ‘apt update’ it shows me below errors –

    ‘E: Failed to fetch http://xx.xxx.x.xx/debs/amd64/Packages 404 Not Found
    E: Some index files failed to download. They have been ignored, or old ones used instead.

    Also when I try installing the package using apt install my_package

    I get below error –

    [email protected]:~# apt install my_package
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package my_package
    [email protected]:~#

    The package is present under the local repo I have created and able to access it download the package from the browser.

    Please tell me how do I resolve this. I have searched the internet but the scenarios are different then mine.

    Thanks.