23.05.2025

How to Configure Repositories on Ubuntu 20.04

Installing software on Linux systems typically relies on repositories, which by default offer a wide selection of packages. However, there are cases when a required application is missing or only an outdated version is available. In such situations, you can add an additional repository and install the desired software from there.

How to configure repositories on Ubuntu 20.04:

Be cautious when adding third-party repositories: they may contain unstable or experimental versions of system components, including the Linux kernel. Always review the description and trust level of a repository before enabling it.

In this guide, we’ll walk through configuring repositories on Ubuntu Server 20.04.

Viewing repositories in Ubuntu

To see all currently active repositories on your system:

nano /etc/apt/sources.list

Repositories may also be listed in individual files located within the /etc/apt/sources.list.d/ directory.

To disable a specific repository, simply comment out its line.

# deb [http://archive.ubuntu.com/ubuntu](http://archive.ubuntu.com/ubuntu) focal multiverse

Adding a repository in Ubuntu

To add a new repository, obtain the address from the software provider and use the apt-add-repository command with this syntax:

apt-add-repository 'deb http://repository_address version branch'

Some repositories require a GPG key to be installed first. Let’s take MariaDB as an example.

apt-key adv --fetch-keys '[https://mariadb.org/mariadb_release_signing_key.asc'

(https://mariadb.org/mariadb_release_signing_key.asc'[/code)]

Now add the repository:

add-apt-repository 'deb [arch=amd64,arm64,ppc64el] [http://mirror.mephi.us/mariadb/repo/10.5/ubuntu](http://mirror.mephi.us/mariadb/repo/10.5/ubuntu) focal main'

Removing repositories

To remove a previously added repository, run the following command:

add-apt-repository --remove 'deb [arch=amd64,arm64,ppc64el] [http://mirror.mephi.us/mariadb/repo/10.5/ubuntu](http://mirror.mephi.us/mariadb/repo/10.5/ubuntu) focal main'

Working with PPA repositories

When adding a PPA repository, the system automatically detects it and fetches the necessary security keys.

apt-add-repository ppa:repository/ppa

To remove a PPA repository:

apt-add-repository --remove ppa:repository/ppa

After modifying the list of repositories, don’t forget to update the package index:

apt update

Conclusion

Properly managing repositories in Ubuntu 20.04 is essential for maintaining a secure and up-to-date system. Whether you’re adding official sources, third-party repositories, or PPAs, understanding how to list, add, and remove them gives you full control over your software environment. Always verify the trustworthiness of external repositories to avoid introducing unstable packages. By following the steps outlined in this guide, you can ensure reliable software installation and smooth system performance.