The developers of the distros usually include their own repositories with useful programs. Also, many developers maintain their own independent repositories to distribute their programs. Even any user can create and maintain their own repository, very useful, for example, to distribute lists of software.
when we install Ubuntu, The distro installs a series of repositories belonging to different channels:
- Main: the repository installed by default. It consists of free FOSS software that can be freely distributed without restrictions.
- Universe: includes free and open source software, but cannot guarantee regular security updates.
- Multiverse: includes software that is from FOSS. It must be the user who analyzes the licenses and decides if they can, or not, use these programs legally.
- restricted: within this channel we can find closed source software. It is used, for example, to distribute NVIDIA drivers, among many others.
- partners: includes proprietary software that has been packaged by Canonical.
And in addition to these repositories, we can also add third-party repositories to our Linux distro to install other types of software safely.
The steps that we are going to see below have been done on Ubuntu, but they should be the same for any Debian-based distro.
How to add new repositories to the software list
The process to add new repositories in Ubuntu can be done both from the graphical interface and through terminal commands.
Using the graphical interface
For users who are taking the first steps in Linux and the command line interface sounds like Chinese, they can use the graphical interface to perform the same processes, but with a much friendlier interface (especially if they come from Windows or macOS). to check both the number of repositories we have installed on the computer and to add new repositories. The first thing we must do is click on Show applications, button located in the lower corner of the screen. Within this section, we must look for software and updates.
Next, click on the Other software tab. If we have any repository installed on the computer, it will be displayed on this tab. From this tab, we can both add new repositories and delete them. To add new repositories, we must click on the Add button. In the text box located just to the right of APT Line, we must write the address of the repository that we want to add to the distribution that we are using (in this case it is Ubuntu). To confirm that we are the legitimate owners of the equipment, we must enter the access password.
Next, the Other Software screen will be displayed again, where, if we have entered the address correctly, the corresponding repository will be displayed.
If we want to delete the repository, we just have to select it and press the Remove button, a process that we must confirm by entering the password to access the account.
From Terminal
To see the list of repositories that we have in our Ubuntu distro, what we must do is open a Terminal (Control + Alt + T) and execute the following command in it:
sudo gedit /etc/apt/sources.list
In case it does not work, or we do not have gedit installed in our distro, we can do it with the following, going to the “nano” editor.
sudo nano /etc/apt/sources.list
As we will see, a list will open with all the repositories that we have in our distro. Repositories (for example, deb http://es.archive.ubuntu.com/ubuntu/ bionic-updates main restricted) starting without # are those that are in use. On the other hand, those that appear at the beginning with a # are those that we have installed, but they are disabled.
If we want to add a new repo, we just have to add it, as follows, at the end of the text file:
deb http://dl.google.com/linux/chrome/deb/ stable main
We save the changes and that’s it. Of course, before updating the repositories and installing any program, we must install the security keys of said repository. These are usually offered together with the PPA, and below we will see an example with the official Google Chrome repo.
Example to add a software source in Ubuntu
To add from terminal a repository, or PPA, for Linux, we must do it as follows. The first thing will be to search the Internet for the repository we want to add. In the case of Google Chrome (this example), we can find it in the .
In the terminal, we will execute the following command to add the keys of the official Google repositories to our Linux. Otherwise, the software in the repositories cannot be validated and will return an error:
wget -q -O – https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add –
Once the previous command has been executed, we can now add the repository to the Ubuntu repository list. And we will do that with the following command:
sudo sh -c ‘echo “deb http://dl.google.com/linux/chrome/deb/ stable main” >> /etc/apt/sources.list.d/google.list’
Obviously, if we have added the repository from GEDIT As we have explained in the previous step, this last command will not be necessary.
Now, first of all, we will have to update the list of Linux repositories to register all the programs in our system and be able to download and install them with apt install.
How to add repositories to other distros
The previous example works for Debian, Ubuntu and any other distro derived from them. However, there are distros that are not based on either of the two, but are independent, as may be the case with Fedora. This distro does not use APT by default, so we cannot use the same system to add software repositories to this Linux. This particular system uses another tool called YUM. Therefore, to add a software source to Fedora, what we have to do is, with root permissions, define the repository inside the “/etc/yum.repos.d/” directory, creating a new file ending in .repo. Once done, we will add it by running the following command:
dnf config-manager –add-repo /etc/yum.repos.d/repository_name.repo
We can also activate a repository by executing the following command, where we must use the ID of the repository in question:
dnf config-manager –set-enabled repository_id
Or disable it, to stop using it, by changing the parameter “–set-enabled” to “–set-disabled” in the previous command.
In case you use a distro like ArchLinux either Manjarowhat we must do is add the third-party software repository to the configuration of pac man. To do this, we edit the following file to add the information of the repository in question:
/etc/pacman.conf
Once the repo, or repos, that interest us to be able to search, download and update software have been added, what we must do is update the software database with the following command:
sudo pacman -Syyu
And ready. We can now start installing software directly from these new sources.
How to update the list of Linux repositories
If we have already added the repositories we want to the list with the previous steps, or we simply want to update our software without adding new repositories, the process is much faster.
The only thing left to do is open a Terminal (Control + Alt + T) in our Linux and execute the following two commands:
- sudo apt update (to update the software listings in the repositories).
- sudo apt upgrade (to download any available packages).
When the process is finished, all our Linux programs, which have been installed through the repositories, will have been updated to their latest version.
We can now install the programs we want from our Linux repositories using apt install (for example: sudo apt install google-chrome).
How to delete a linux repository
It may be that with the passage of time we no longer need a Linux repository in our distro. Either because it has become part of its official repositories, or simply because we no longer use the program.
It may also happen that the repository has stopped working and, because of it, we are having errors when updating the software lists or updating our Linux distro.
To delete the repository, what we must do is open the list of software repositories with the following command:
sudo gedit /etc/apt/sources.list
The gedit text editor will open with the list of all the repositories that we have added. We simply have to locate the repository we want to delete and remove it from the list. We can also comment it out with pads, like comments, so it’s disabled.
The repository is already deleted. Now updating the list with sudo apt update and the changes will be reflected in our distro.
Remove PPA
In case we have added the repository through a PPA, removing it is a fairly simple task. The only thing we will have to do is execute the following command in the terminal, adding the URL of the PPA that we want to delete at the end:
sudo add-apt-repository -r ppa:repo/repo
If the repository had a key associated with it, we can remove it using the command “sudo apt-key del” followed by the numeric key in quotes or its last 8 characters (without quotes).
We update the software list with “sudo apt update” and that’s it. We will already have the list of software without the programs from the source that we have just deleted.
Differences between deleting a PPA or deleting a program
We should never confuse a PPA, or repository, with a program. Software repositories are servers that tell the package manager (for example, APT) where to look for programs. However, the repository does not have much to do with the program as such that we install on our computer.
If we delete the PPA of a program, it will continue to be installed on the computer. What’s more, we are going to put ourselves in danger since, by doing so, the program will no longer be able to search for and download updates through the package manager that we use. For example, if we delete the Chrome repository, we will stop updating the browser, with the risks and problems that this entails.
Having repositories in Linux does not imply any problem for the computer. The only thing that, when updating them, will take longer than necessary. It is a good maintenance practice, yes, but always making sure not to leave any program hanging. Ideally, first, delete the program that we no longer need, and clean all the remains that it may have left. And, once deleted, then delete the repository.
Problems updating Linux repositories
Although the normal thing is that everything goes well, and in a few seconds we have the updated software lists, there can be several reasons why the repos are not updated correctly. When this happens we must not lose our cool, since with a couple of simple commands we will be able to solve most of the problems.
Error Sub-process /usr/bin/dpkg
This error message…