add-apt-repository Command Examples

add-apt-repository is a command line utility that is used to add or enable a repository in the APT (Advanced Packaging Tool) package manager on Debian, Ubuntu, and other Debian-based Linux distributions.

A repository is a collection of software packages that are stored on a remote server and made available for installation on your Linux system. The add-apt-repository command allows you to add a repository to your system’s APT sources list, which is a configuration file that APT uses to find and install packages.

To use add-apt-repository, you need to provide it with the URL of the repository you want to add. For example:

$ sudo add-apt-repository "deb https://myrepo.com/ubuntu bionic main"

This will add the repository at the URL https://myrepo.com/ubuntu to your APT sources list and enable it for installation. You will then need to update your package list using the apt update command before you can install any packages from the new repository.

Keep in mind that you should only add repositories from trusted sources, as adding a repository from an untrusted source could potentially compromise the security of your system.

add-apt-repository Command Examples

1. Add a new apt repository:

# add-apt-repository {{repository_spec}}

2. Remove an apt repository:

# add-apt-repository --remove {{repository_spec}}

3. Update the package cache after adding a repository:

# add-apt-repository --update {{repository_spec}}

4. Allow source packages to be downloaded from the repository:

# add-apt-repository --enable-source {{repository_spec}}
Related Post