/etc/apt/sources.list - SourcesList file in Ubuntu

In this article, we would discuss a bit about SourcesList file i.e. /etc/apt/sources.list in Ubuntu distribution. There are two components, which are responsible for download and installation of various packages.

  1. APT or Advanced Package Tool basically fetches packages available through repositories. Thereafter, the downloaded packages are installed on our system.
  2. A repository – It could be a network server. We can also provide path of Directories/CD/DVD as repository. In a repository, we have organized set of binary and sources packages. The repositories also contains files which have all the information about available packages. So, we could get list of packages available and their versions, information about their maintainers etc. Hence, we could decide what all packages need to be installed on our system.

Before downloading a package available in a repository, we need to provide the repository location to the Advanced Package Tool. This could be done through /etc/apt/sources.list file. It contains the path of all the repositories. Although, we could add a repository through add-apt-repository command-line utility which is already explained Add or Remove PPAs in Ubuntu. But, for the purpose of this article we would limit ourselves to the editing of /etc/apt/sources.list file through a text-editor.

Note: Editing a /etc/apt/sources.list file would require you to have superuser privileges. You can’t edit the SourcesList through normal user. Otherwise, you may get the following error –

/etc/apt/sources.list permission denied

SourcesList file in Ubuntu distribution

Any /etc/apt/sources.list file would contain syntax similar to –

deb http://<domain-name>/ubuntu/ distribution component1 component2 component3
deb-src http://<domain-name>/ubuntu/ distribution component1 component2 component3


deb tells us that the repository contains binary packages

deb-src for source code of packages

http://<domain-name>/ubuntu/ – is the URI (Uniform Resource Identifier)

distribution – release of the Ubuntu package, for instance – if its Ubuntu 20.04 then it would be focal.

component – these could be free/non-free as per the packages available in repository

For Ubuntu distribution, we have four components of repositories –

  1. Main – Packages are free/open-source and supported by Canonical.
  2. Universe – Package are free/open-source and maintained by community.
  3. Restricted – These contain proprietary drivers for various devices.
  4. Multiverse – These package are restricted due to legal/copyright issues.

You could add any or all of the above components in Ubuntu distribution as per your requirements.

Once you make changes to the /etc/apt/sources.list file, don’t forget to update the repository. This ensures that information about the packages are updated and you always get the latest version of packages. To update the repository, issue the following in terminal –

sudo apt update

In conclusion, we have discussed /etc/apt/sources.list (SourcesList) file in Ubuntu distribution.

Additional Info

It is worth mentioning here that, installing a package through repository offers its own set of advantages. Foremost being, you don’t have to track and update each of the packages installed manually. Consider a scenario, where you install hundred of packages through dpkg command-line utility. And, now you have to download each of those packages and update them manually.

Under such scenario, it is better to install packages through repository as far as possible. APT will take care of the rest when you update the repository and upgrade the packages.

Similar Posts