Ubuntu Repositories. You have heard about them before. You use it whenever you try to download, install, remove, or update a package on Ubuntu.
So, does Ubuntu keep all of them in your OS? Or a remote place?
In this article, we’ll learn about Ubuntu repositories, how it works, and how you can deactivate/activate them.
Let’s get started.
What are Ubuntu Repositories?
Ubuntu repositories are software archives maintained by Ubuntu. They’re hosted over the network (internet), where anyone can use them to gain access to Ubuntu tools and software.
The repositories contain hundreds and thousands of software. All of these are accessible to the general users. You can also think of repositories as software archives.
Repositories aim to provide a secure, centralized place to access software for your needs. These Ubuntu repositories follow strict rules when adding software. Each software is tested thoroughly with the Ubuntu version before making it available on the repository.
As Ubuntu is Debain-based, it uses an APT package manager to handle the packages. The packages are in .deb format, containing the libraries and programs you need to run your tasks.
This approach differs from macOS and Windows as they don’t offer a dedicated yet trusted place to access software, especially regarding a well-packed format. In Linux, you’ll find different package formats for different flavors. For example, you have DEB packages for Debian, whereas RPM is for RHEL-based distros.
As Ubuntu uses an APT package manager, you must use the apt command to install software in Ubuntu.
Let’s learn more about package managers to understand how Ubuntu repositories work.
How Does Ubuntu Repository Works With Package Manager?
To understand the Ubuntu repository, we must look at how the package manager works.
A package manager is a set of software that lets you manage packages on your Linux distro. So, with a package manager, you can install, upgrade, remove, or configure packages on your system.
This leads us to the concept of repositories.
The repositories are a virtual place that lists all the packages. Here, each package has its metadata information.
So, when you try to perform an action such as update, search, or install, the package manager works with the software repository to act successfully.
For example, if you’re trying to install a package, the package manager will try to look for it in the package repository and then proceed with the installation.
However, before the package manager interacts with the repository directly, it consults its local metadata cache for information. Using a local cache removes the need to connect to the remote repository every time you run a command. Also, if the cache is outdated, it’ll fail to install the software and likely throw an error, “Unable to Locate Package.”
This means you’ll need to update your local cache before installing or updating any package.
Types of Ubuntu Repositories
Ubuntu repositories are divided into four main categories. These include:
Personal Public Archive (PPA)
Generally, an average needs to learn about them. However, if you want a complete grasp on the Ubuntu repository, you must know about these, as each repository type offers something different.
The Main Ubuntu repository is the home of free software. Any software listed here is free to redistribute. Also, the Ubuntu team supports the free software. All these make the Main component popular, giving users access to popular open-source apps. Community, users, and Ubuntu developers maintain the main repository software list. They hand-pick the software to provide value to the end users. Also, each software receives security updates alongside Canonical technical support.
Note: This is also enabled by default when you first install Ubuntu.
The Restricted component deals with non-free tools and drivers. Even though Ubuntu is all about open source, users must get access to proprietary tools and drivers to make underlying hardware or tools work. This also means that Ubuntu developers or the community cannot update the software listed in Restricted, leaving the update work for the original developers.
The Universe repository hosts free and open source software. However, unlike the Main repository, you won’t get regular security updates as Ubuntu doesn’t manage it. Hence, the Universe’s repository is maintained by the community. As Ubuntu is community-driven, you get access to thousands of excellent software.
The Multiverse repository component deals with the non-FOSS software. You can access non-free software with legal and licensing costs or issues here. So, if you opt to use Multiverse, you must do your homework before downloading or installing software from the repository.
#5. Personal Public Archive (PPA)
PPA repositories are managed by individuals and developer teams to host their software or a plethora of other software. They offer an easy way to get packages unavailable via other repository types.
Activating/Deactivating Ubuntu Repositories Types
You can activate/deactivate Ubuntu repository types (main, universe, multiverse, and restricted) through a graphical interface or by running commands.
Let’s look at both methods below.
#1. Using Graphical Interface
To turn the Ubuntu repository type on/off graphically, you must open “Software and Updates.”
You can access it by searching or accessing Applications > Software and Updates.
By default, all four repositories are enabled. You can turn these options on/off and close them for it to take effect.
If you want to enable the partner repository, go to the Other Software tab and then tick the option “Canonical Partners.”
#2. Using Commands
You can use commands to enable the Ubuntu repository type.
You can also enable all four of them in one command.
$ sudo add-apt-repository main restricted universe multiverse
sudo add-apt-repository main restricted universe multiverse
Adding component(s) 'main, restricted, universe, multiverse' to all repositories.
Press [ENTER] to continue or Ctrl-c to cancel.
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
If you want to remove the repository, you need to run the same command with the -r argument. For example, check the command for removing the Universe repository.
$ sudo add-apt-repository -r universe
For disabling/deleting, you’ll need to edit the sources.list file or use the graphic interface method.
You can edit the sources.list file by running the following command.
$ sudo gedit /etc/apt/sources.list
If you don’t have Gedit installed, you can use Vim or install Gedit with the following command.
$ sudo apt-get install gedit
As you can see in the image above, you can uncomment the lines of the repository you want to remove.
PPA: Where it stands in comparison to Ubuntu Repositories
Apart from the four main types of Ubuntu repositories, there is one more type that you must know, i.e., PPA (Personal Package Archive).
PPA is created and managed by individual teams or developers to provide a central software repository for users. They offer benefits over traditional repositories with improved compatibility, faster updates, and unofficial package support.
However, if you want more reliability and trust, nothing beats Ubuntu repositories, which are managed officially.
To use PPA, you need to add it to your system’s repository list.
Also, there are two types of PPA: official and unofficial. Canonical or other trusted organizations manage the official PPA repositories. These official PPAs are considered safe to use. On the other hand, the unofficial PPA repositories are not affiliated with Ubuntu in any form or way. This means 3rd-party organizations and individuals create them — making them unreliable.
Ubuntu Repositories Commands
In this section, we’ll summarize the different commands for repositories.
List of Repositories
To list all the repositories on your system, run the following command.
$ nano /etc/apt/sources.list
The repository file is sources.list, located at /etc/apt/ folder.
However, you can find it in other locations: /etc/apt/sources.list.d/ folder.
The file is completely editable, and you can disable repositories by commenting on the respective line.
# deb http://archive.ubuntu.com/ubuntu focal multiverse
Adding New Repositories
As discussed earlier, you can add a repository by running the apt-add-repository command. It differs from add-apt-repository, which requires you to provide the Repository name as input.
$ apt-add-repository ‘deb http://repository_address version branch’
You’ll need to enter the repository address, associated version, and branch here.
Also, when you add a repository, you might have to install its GPG security key.
Removing repositories can be done by using the following command.
$ add-apt-repository --remove ‘deb http://repository_address version branch'
PPA Repository in Ubuntu
Adding a PPA repository in Ubuntu requires you first to install the software-properties-common package. You can do it by using the following command.
$ sudo apt-get install software-properties-common
Once done, you can add the PPA repository using the following command.
$ sudo add-apt-repository ppa:user/repo
So, if you want to add notepadqq PPA, you need to run the following command.
Similarly, you can remove a PPA using the following command.
$ sudo add-apt-repository --remove ppa:user/repo
Ubuntu is an excellent Linux distro. It provides new users with an easy way to introduce themselves to the world of Linux. The Ubuntu repositories are a fine example of how Ubuntu manages packages along with its own APT package manager.
Now that you understand entirely how Ubuntu repositories work, you can now customize them to your needs.