+4 votes
277 views
How to update the list of Linux repositories

in Linux / Unix by (551k points) | 277 views

1 Answer

+3 votes
Best answer

Keep Linux always up-to-date: the right way to update your repositories
What are Linux repositories?
How to add new repositories to the software list
How to update the list of Linux repositories
How to delete a Linux repository
Different types of repositories in Ubuntu
Example to add Google Chrome repository from Terminal
Delete PPA

Keep Linux always up-to-date: the right way to update your repositories

What are Linux repositories?

The repositories are one of the best features that Linux. A repository is a list of programs, generally always updated, that allows us to easily search for and download all kinds of programs and tools in our distribution.

Thanks to the repositories we will be able to have a safe and reliable place from which to download software and the latest updates of all our programs. These programs will be installed without any type of dependency problem, and we can also update our entire repertoire of programs with a simple command.

The developers of the distros usually include their own repositories with useful programs. Additionally, many developers maintain their own separate repositories to distribute their programs. Even any user can create and maintain their own repository, very useful, for example, to distribute software lists.

Different types of repositories in Ubuntu

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 the FOSS. It should be the user who analyzes the licenses and decides whether or not they can 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.
  • Partner: 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 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

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 doesn't work, or we don't have gedit installed on our distro, we can do it with the following, going to the editor «nano».

sudo nano /etc/apt/sources.list 

List of repositories in Linux

As we will see, a list will be opened with all the repositories that we have in our distro. Repositories (eg deb http://es.archive.ubuntu.com/ubuntu/ bionic-updates main restricted) starting without # are those 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, to the end of the text file:

deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

We save the changes and voila. Of course, before updating the repositories and installing any program we must install the security keys of said repository. These are usually offered with the PPA, and then we will see an example with the official repo of Google Chrome.

Example to add Google Chrome repository from Terminal

To add a Linux repository, or PPA, from terminal , we must do it as follows. The first thing will be to search the Internet for the repository that we want to add. In the case of Google Chrome (this example), we can find it on the Google website .

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 [arch=amd64] 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 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 update the list of Linux repositories

If we have already added the repositories we want to the list with the previous steps, or simply want to update our software without adding new repositories, the process is much faster.

The only thing we have 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 lists from the repositories).
  • sudo apt upgrade (to download available packages).

Update Linux repositories

When the process ends, all the programs of our Linux, which have been installed through the repositories, will have been updated to their latest version.

We can now install the programs that we want from our Linux repositories using apt install (for example: sudo apt install google-chrome).

How to delete a Linux repository

Maybe 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 can also happen that the repository has stopped working and, because of you, we are having errors 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 need to locate the repository that we want to remove and remove it from the list. We can also comment it with pads, like comments, so that it is disabled.

The repository is now removed. Now updating the list with sudo apt update and the changes will be reflected already in our distro.

Delete PPA

In case we have added the repository through a PPA, deleting it is quite a simple task. The only thing we will have to do is execute the following command in the terminal, adding at the end the URL of the PPA that we want to delete:

sudo add-apt-repository -r ppa:repo/repo

If the repository was associated with a key, we can delete it using the command "sudo apt-key del" followed by the numeric key in quotation marks or its last 8 characters (without quotation marks).

We update the software list with "sudo apt update" and voila.


by (551k points)

Related questions

+3 votes
1 answer
asked Feb 17, 2020 in Linux / Unix by backtothefuture (551k points) | 277 views
+3 votes
1 answer
asked Nov 2, 2019 in Linux / Unix by backtothefuture (551k points) | 245 views
+4 votes
1 answer
asked May 22, 2019 in Linux / Unix by backtothefuture (551k points) | 160 views
+3 votes
1 answer
asked May 14, 2019 in Linux / Unix by backtothefuture (551k points) | 246 views
+4 votes
1 answer
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users