How to Fix the “add-apt-repository: command not found” error

The core part of the Ubuntu operating system is its terminal and its repositories which are accessed using this terminal. These repositories contain large amounts of packages and software that can be installed onto the system using simple commands. The “apt” is the default package manager of Debian-based systems to install/remove/upgrade packages from the repositories. It comes pre-installed onto the Ubuntu system. While attempting to add external repositories an error with the statement “add-apt-repository: command not found” may occur.

This article will act as a guide to help you figure out the reasoning behind this problem as well as the measures that can be taken to resolve this issue.

Methods to Resolve “add-apt-repository: command not found”

When adding external repositories such as PPA (Personal Package Archive) this error may be invoked. Let’s dive deeper into this error and check out its major reason.

Reason: Package “add-apt-repository” is not installed

The “command not found” is a very common error and every time that it pops up, the reason is that the package is simply not installed on the system. In this scenario, that package would be the “add-apt-repository” package. To check if this package is installed on your system or not, simply run the code shown below:

$ sudo add-apt-repository

If the output is not similar to the one displayed above, that indicates that the system does not have the access to use the command “add-apt-repository”.

Solution: Install the “add-apt-repository” Package

The most obvious fix to this error is to install the “add-apt-repository” package onto your system. But this package is not installed using this name. It is a part of a much bigger package that will be installed onto the system. Updating the system repository is the first and one of the most important steps. To achieve this, run the following simple command:

$ sudo apt update

Once updated, the next and the most important step is to install the software-properties package onto the system. This package contains the “add-apt-repository” feature as well. To install this package, execute the command as shown below:

$ sudo apt install software-properties-common

Installing this package will allow you to execute the “add-apt-repository” command without the error. To test this, we are adding a PPA repository using the command demonstrated below:

$ sudo apt-add-repository "deb http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu focal main"

The successful addition shows that the problem no longer persists.

Conclusion

The “add-apt-repository: command not found” problem occurs when the system does not have the “add-apt-repository” package installed on it. To install this package, the system repository needs to be updated and then the “software-properties-common” package needs to be installed. This package contains the “add-apt-repository” tool and the error will no longer be invoked once it is installed. This article successfully provides in-depth knowledge of the reasoning behind this issue and its possible solution.