How do the vast number of Linux packages available online make their way onto our computers? While you could visit the download page for each piece of software, a much more efficient solution exists: package repositories.
What is a Package Repository
A package repository is a central storage location for software. These repositories, hosted on servers across the internet, contain curated collections of Linux packages, eliminating the need for manual downloads and installations. This system is a cornerstone of modern Linux package management, providing a streamlined and secure way to manage software.
How Repositories Work
Your system's package manager needs to know where to find these repositories. You provide it with a source link, and it handles the rest.
For example, to install Docker, you don't download it directly from their website. Instead, you configure your package manager to use Docker's official repository, which is hosted at a URL like https://download.docker.com/linux/ubuntu. Once configured, your system can access all the packages within that repository, such as docker-ce, docker-ce-cli, and containerd.io.
Configuring Repository Sources
Your Linux distribution already comes with a set of pre-configured repositories for all the base packages on your system. On Debian-based systems like Ubuntu, the primary configuration for these sources is managed through the apt sources list.
Traditionally, this list is a single file: /etc/apt/sources.list. Your machine's package manager reads this file to know which repositories to check for available software and updates.
It is also common practice to add new repository configurations in the /etc/apt/sources.list.d/ directory. Newer Ubuntu versions (22.04+) even use this directory by default, organizing sources into structured .sources files. This approach keeps third-party repositories separate from the system's default sources, making package management cleaner and more organized. Both /etc/apt/sources.list and files within /etc/apt/sources.list.d/ are used by the apt package manager.