Americas

  • United States
sandra_henrystocker
Unix Dweeb

How to list repositories on Linux

How-To
Sep 18, 20185 mins
Linux

Knowing which repositories you are using can shed light on how your system manages updates.

A Linux repository is a storage location from which your system retrieves and installs OS updates and applications. Each repository is a collection of software hosted on a remote server and intended to be used for installing and updating software packages on Linux systems. When you run commands such as “sudo apt update” or “sudo apt upgrade”, you may be pulling package information and package updates from a number of repositories.

Repositories contain thousands of programs. Standard repositories provide a high degree of security, since the software included is thoroughly tested and built to be compatible with a particular distribution and version. So, you can expect the updates to occur with no unexpected “side effects.”

Repositories may be standard or non-standard. Once a non-standard repository has been added to your system’s list of repositories, the system can install software from it, as well as from the standard ones; otherwise, it cannot. In general, adding a non-standard repository is a simple step. The sudo apt-add-repository command on Ubuntu, for example, can be used to add a repository. The –help option for the apt-add-repository command shows these command examples:

    apt-add-repository 'deb http://myserver/path/to/repo stable myrepo'
    apt-add-repository 'http://myserver/path/to/repo myrepo'
    apt-add-repository 'https://packages.medibuntu.org free non-free'
    apt-add-repository http://extras.ubuntu.com/ubuntu
    apt-add-repository ppa:user/repository
    apt-add-repository ppa:user/distro/repository
    apt-add-repository multiverse

The apt-add-repository command also supports removing a repository with use of the -r option.

On Fedora, the command for adding a repository looks like this:

dnf config-manager --add-repo repository_url

You should be careful, however, when adding a non-standard repository to be sure that it has been tested and is known to work on your particular system.

If you’re curious about which repositories your system is using, you can issue a command on the command line to have your Linux system provide that information to you.

RPM-based systems

On RedHat, Fedora and similar systems, you would use a command like the one shown below to view the repositories that your update commands use. Note that we’re using the dnf command in this example. This is the replacement for the older yum command.

$ sudo dnf repolist
Last metadata expiration check: 0:18:37 ago on Sat 15 Sep 2018 12:28:02 PM EDT.
repo id        repo name                            status
*fedora        Fedora 28 - x86_64                   57,327
*updates       Fedora 28 - x86_64 - Updates         18,739

The status field in the output above represents the number of packages in each of the repositories. If you add the “all” specification, you will also see disabled (not used) repositories. In the command below, we see that quite a number of other repositories are disabled.

$ sudo dnf repolist all
Last metadata expiration check: 0:19:39 ago on Sat 15 Sep 2018 12:28:02 PM EDT.
repo id                            repo name                        status
*fedora                            Fedora 28 - x86_64               enabled: 57,327
fedora-cisco-openh264              Fedora 28 openh264 (From Cisco)  disabled
fedora-cisco-openh264-debuginfo    Fedora 28 openh264 (From Cisco)  disabled
fedora-debuginfo                   Fedora 28 - x86_64 - Debug       disabled
fedora-source                      Fedora 28 - Source               disabled
*updates                           Fedora 28 - x86_64 - Updates     enabled: 18,739
updates-debuginfo                  Fedora 28 - x86_64 - Updates - D disabled
updates-source                     Fedora 28 - Updates Source       disabled
updates-testing                    Fedora 28 - x86_64 - Test Update disabled
updates-testing-debuginfo          Fedora 28 - x86_64 - Test Update disabled
updates-testing-source             Fedora 28 - Test Updates Source  disabled

Enabling a repository can be done with a command like this:

# dnf config-manager --set-enabled repository_url

You can also add repositories fairly easily with commands like this:

# dnf config-manager --add-repo http://www.example.com/example.repo

Debian-based systems

For Debian systems such as Ubuntu, you could use a command like the one shown below to list the repositories that are used when you update your system. This command selects sources from the /etc/apt/sources.list file and /etc/apt/sources.list.d directory on the system where this information is maintained. The ^[^#] argument is suppressing the comments.

$ 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
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security main restricted
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security universe
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security multiverse
/etc/apt/sources.list.d/teejee2008-ubuntu-ppa-bionic.list:deb http://ppa.launchpad.net/teejee2008/ppa/ubuntu bionic main

One thing you might notice when looking at the listing above is the use of the terms restricted, universe, and multiverse. These terms identify some important distinctions:

  • Main – officially supported, open-source software. Canonical provides official support for these packages. Every open-source software package included in the default installation is included along with some other important packages.
  • Restricted – officially supported, closed-source software – e.g., hardware drivers — supported for the length of the release.
  • Universe – community-maintained, open-source. The majority of the Ubuntu software comes from this repository. Canonical does not provide official support or updates.
  • Multiverse – unsupported, closed-source and patent-encumbered software.

Wrap-up

Standard Linux repositories provide:

  • Reliable locations to get software with confidence, knowing that it’s free from malware and properly tested
  • Simple installations without concerns for dependencies (all the required packages are provided)
  • Easy ways to find and download what you need

Knowing which repositories you are using can shed light on how your system manages updates. In general, this is very straighforward. If you use non-standard repositories, it’s probably a good idea to occassionally review your software sources.

sandra_henrystocker
Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author