Skip to Content

How to list repository in Linux

In Linux, a repository is a collection of software packages that are available for installation on your system.

Think of it as an app store for Linux systems. Repositories make it easier to find, install and update applications, without having to manually compile the source code.

In this article, we’ll explain how to list the repositories on your Linux system, and how to add new repositories.

List Repositories in Redhat CentOS and Fedora

Yum is a package manager for Redhat and CentOS distributions. It allows you to search, install, update, and remove packages from the repositories.

To list the available repositories, use the following command:

yum repolist

This will show all of the repositories configured on your system and whether they are enabled or not.

For example:

repo id repo name status
base/7/x86_64 CentOS-7 - Base enabled: 5,867
extras/7/x86_64 CentOS-7 - Extras enabled: 394
updates/7/x86_64 CentOS-7 - Updates enabled: 1,567

The “status” column indicates whether the repository is enabled or disabled. If a repository is not enabled, you won’t be able to install packages from it.

To view only enabled repositories in YUM, use yum repolist enabled

You can list only disabled yum repositories as well. Use yum repolist disabled

You can also get all the repositories from the configuration file.

$ cat /etc/yum.repos.d/*

The /etc/yum.repos.d directory contains all the repositories configured for yum-based systems such as Redhat, CentOS and Fedora.

Each repository is represented by a single file with an “.repo” extension.

For example, if you have enabled the epel repository, then you should see a file named epel.repo in the directory.

You can view the contents of each repository configuration file to get more information about it.

List Repositories in Debian and Ubuntu

The Advanced Packaging Tool (APT) is the package manager for Debian and Ubuntu distributions. It allows you to search, install, update and remove packages from the repositories. To list the available repositories on your system, use the following command:

apt-cache policy

This will show all of the repositories configured on your system and whether they are enabled or not.

For example:

Package files:
100 /var/lib/dpkg/status
release a=now
500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
release v=16.04,o=Ubuntu

Or you can get all the repositories from the configuration file.

$ cat /etc/apt/sources.list /etc/apt/sources.list.d/*

The /etc/apt/sources.list is a text file that contains all of the repository locations that have been registered on your system.

The /etc/apt/sources.list.d directory contains files that specify additional repositories to be used by APT. This is a convenient way to add new repositories, without having to edit the main sources.list file.

Here is one example of my system.
$ grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*
/etc/apt/sources.list:deb <http://us.archive.ubuntu.com/ubuntu/> bionic main restricted
/etc/apt/sources.list:deb <http://us.archive.ubuntu.com/ubuntu/> bionic-updates main restricted
/etc/apt/sources.list:deb <http://us.archive.ubuntu.com/ubuntu/> bionic universe
/etc/apt/sources.list:deb <http://us.archive.ubuntu.com/ubuntu/> bionic-updates universe
/etc/apt/sources.list:deb <http://us.archive.ubuntu.com/ubuntu/> bionic multiverse
/etc/apt/sources.list:deb <http://us.archive.ubuntu.com/ubuntu/> bionic-updates multiverse

Add New Repositories in Linux

You can add new repositories to your system by adding the repository URL to the appropriate configuration file.

For example, on Redhat/CentOS systems, you can add a new repository in the /etc/yum.repos.d/ directory by creating a new file with the .repo extension.

For example, to add the EPEL repository:

$ touch /etc/yum.repos.d/epel.repo

And then add the repository URL to the file. For more detailed info, you can check this article from Redhat.

For Debian/Ubuntu systems, you can add a new repository in the /etc/apt/sources.list file by adding a line with the URL of the repository.

The URL can usually be found on the website of the software provider (e.g., for Ubuntu, it would be http://us.archive.ubuntu.com/ubuntu/).

Once you have the URL, open the /etc/apt/sources.list file in a text editor (e.g., Nano or Vim) and add the URL to the end of the file, like so:

deb http://us.archive.ubuntu.com/ubuntu/ bionic main

Save your changes and exit the text editor, then run sudo apt update to refresh the repositories. You should now find that the new repository has been added successfully and is available for use.

Conclusion

Listing and adding repositories in Linux is a relatively straightforward process, once you know what tool to use. By following the steps above, you should have no trouble managing your system’s repositories. If in doubt, however, remember to consult the documentation of your Linux distribution for more information.