APT Repository List [An Essential Guide]

APT (Advanced Package Tool), is a  package managing toolkit primarily responsible for repository configuration in Ubuntu and other Debian-centric Linux distros. APT uses a list of repositories to fetch software packages and updates. In this writing, I will discuss the basics & configuration of apt repositories in-depth along with some useful practical examples using the command line.

What is the APT Repository List?

APT repository list is a configuration file that contains a list of repositories from which APT fetches software packages. These repositories provide a wide range of software applications, updates, and security patches for your Linux system. Managing this list allows you to control which software is available for installation or update.

The APT Repository Configuration in Linux

Apt operates on top of repositories for software installation, updation, or even removal. It stores a list of repositories or software channels in the ‘/etc/apt/sources.list’ & ‘/etc/apt/sources.list.d/’ files. And, inside the repository list, you will find the URLs or addresses of the software repositories that APT should use to download & install packages.

So, knowing about the configuration file structure for software package management is a prime concern. Now about these two files:

  1. /etc/apt/sources.list: The primary file enlisting official repos. You can enable or disable any additional repositories by simply using the terminal that edits the file automatically.
  2. /etc/apt/sources.list.d/: A directory storing the configuration files with the .list extension. The sources.list file is also located here. You can add any necessary repository to use the required software by utilizing a .list file.

NOTE: Repository files in the ‘/etc/apt/sources.list.d’ directory must have file names ending with ‘.list’.

Components of APT Repository Entry

Each repository entry in the list specifies the location of the repository, the release code name (i.e., focal, bionic. etc.), and the sections of packages (main, restricted, universe, multiverse) available in that repository. The general syntax for entries in ‘/etc/apt/sources.list’ contains:

  • deb These repositories contain binaries or precompiled packages. They are required for most users.
  • deb-src They contain the source code of the packages. These are useful for developers.
  • URL This is the web address where the repository is hosted. For example, ‘http://archive.ubuntu.com/ubuntu/’ is the URL for the official Ubuntu repository.
  • Release Code Name Represents the code name of the specific Ubuntu release version, such as ‘jammy’ for Ubuntu 22.04.2 LTS.
  • Sections Ubuntu repositories are divided into four main sections:
  • main: Contains officially supported open-source software & maintained by the Ubuntu community.
  • restricted: Proprietary software that is supported by Ubuntu but not open-source.
  • universe: Community-maintained open-source software.
  • multiverse: Contains proprietary or restricted software not supported by Ubuntu.

Each section contains different software packages and users can choose which repositories to include in their system’s repository list based on their software requirements & preferences.

Managing APT Repositories in Ubuntu

Setting up software repositories using the CLI is a common practice for Linux users. You can manage your repositories by configuring apt repositories. More elaborately by adding, removing, and updating software sources, your system uses to install and update packages. Here’s how you can manage your repositories using a set of simple commands:

1. Listing the APT Repositories

To display the list of Ubuntu Repositories configured on your system, you can check the contents of the ‘/etc/apt/sources.list’ file and the files within the ‘/etc/apt/sources.list.d’ directory. You can also use the ‘apt-add-repository’ command with its option ‘–list’ to view all the repos lists. For that, use the command syntax:

sudo add-apt-repository --list
EXPLANATION
  • sudo: Grants superuser privileges
  • add-apt-repository: Command that adds/removes apt repositories.
  • –list: Command option to list the current repositories.
View List of APT repositories From the image, you can see the list of apt repositories currently available on my system.

2. Add a New APT Repository

Adding a new apt repository is a way to install software packages that are not available in the default repositories. To add a new repository, you can directly edit the ‘sources.list’ file or use the ‘add-apt-repository’ command.

Now, I will configure an apt repository for installing Chrome Browser. You can do the same by running the following command:

sudo add-apt-repository ‘deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ jammy main’
EXPLANATION
  • deb: Repository type in Debian-based distro such as Ubuntu.
  • [arch=amd64]: Architecture.
  • https://dl.google.com/linux/chrome/deb/: Repository URL.
  • jammy: Release codename for Ubuntu 22.04.
  • main: Indicates software packages are within the main repository.

Adding a new APT repository Within the execution of the command, it starts the installation process of the Chrome repository. Press ENTER for the confirmation & it will be installed automatically. Similarly, you can add the URL of the repository you intend to install.

3. Remove an Existing APT Repository

Sometimes when you want to remove repositories that you no longer need, you can utilize the apt-add-repository command with the –remove option for a smooth deletion of those repositories.

Here, I will remove the previously added Chrome Browser. You can do the same by running the following command:

sudo add-apt-repository --remove ‘deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ jammy main’
EXPLANATION
  • –remove: Option of the add-apt-repository command to delete the repository.
  • https://dl.google.com/linux/chrome/deb/: Repository URL.

NOTE:  You can disable any repositories, by just commenting out (by adding a ‘#’ at the beginning of the line) the corresponding repository lines from the ‘/etc/apt/sources.list’ configuration file.

Removing an APT repository As you can see from the image, I have removed the Chrome repository from my system.

4. Update Repository Lists

After modifying your repo list, you always need to update the package list to reflect the changes. This can be done by the following command:

sudo apt update

Update Repository List

NOTE: Running thesudo apt update command is an essential step after any repo modification to refresh the package information so that your system is aware of the latest changes.

APT Repository Mirror and Repository Proxy

Enhancing the software experience by improving download speeds and quick access to essential packages is crucial in the field of software package management. Two significant ways are known as Repository Mirrors and Repository Proxies. Check out the following section for more details on them:

APT Repository Mirror

The apt package manager usually installs and updates software by connecting to the official repositories. However, the central server may face a heavy load of traffic from time to time. This frustrates the faster download of the software. A repository mirror can be effective in situations as such.

The mirrors are duplicates of the official repositories. So, you can connect to the closest mirror based on the geographical location and ensure a quicker download of the software.

Learn more about repository mirrors from ‘The Repository Mirror in Ubuntu’.

Benefits of Using Mirrors

  • Faster package downloads, especially during peak times.
  • Reduced strain on the primary repository servers.
  • Increased reliability and availability of packages.

APT Repository Proxy

Also called APT Proxy, the apt repository proxy acts as an intermediary between your system and the remote repositories. It takes the system request and handovers to the external repository (either main or mirror) for further processing by functioning as the bridge between the repository server and the system user.

Learn more about the repository proxy from ‘How to Add an APT Repository Proxy in Ubuntu

Benefits of Using Proxies

  • Reduced bandwidth usage, particularly in environments with multiple Linux systems.
  • Faster package installations and updates due to local caching.
  • Enhanced control over which packages are cached and for how long.

Conclusion

Managing APT repository lists is a fundamental skill for any Linux user. By following the simple steps discussed in this writing, you can add, remove, and update repositories as needed to keep your system up to date and access to a wide range of software packages.

People Also Ask

How do I list repositories in apt?

To list the repositories configured in the APT (Advanced Package Tool), you can use the ‘add-apt-repository’ command with the command option ‘–list’. For that use the command syntax ‘sudo add-apt-repository –list‘.

Where is apt repository list?

The apt repository list is typically stored in the ‘/etc/apt/sources.list’ file and in files within the ‘/etc/apt/sources.list.d/’ directory on Debian-based Linux distributions such as Ubuntu, and their derivatives.

What is apt list in Linux?

The ‘apt list’ command in Linux is used to list packages that are available in the APT (Advanced Package Tool) package management system’s database. APT is mainly used on Debian-based Linux distributions such as Ubuntu, and their derivatives.

Can I use apt on Linux?

Yes, you can use the ‘apt’ command in Linux, particularly on Debian-based Linux distributions such as Debian, Ubuntu, Linux Mint, and others. APT (Advanced Package Tool) package management system that allows you to install, update, and manage software packages on your Linux system.

Related Articles


<< Go Back to Linux Repository List | Package Management in Linux | Learn Linux Basics

5/5 - (1 vote)
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
Monira Akter Munny

Hello!! This is Monira Akter Munny. I'm a Linux content developer executive here, at SOFTEKO company. I have completed my B.Sc. in Engineering from Rajshahi University of Engineering & Technology in the Electrical & Electronics department. I'm more of an online gaming person who also loves to read blogs & write. As an open-minded person ready to learn & adapt to new territory, I'm always excited to explore the Linux world & share it with you! Read Full Bio

Leave a Comment