How to fix add-apt-repository command not found error on Debian and Ubuntu

Ubuntu and Debian add-apt-repository command not found” error appears when trying to add a new software repository. This indicates that the add-apt-repository package is missing on your system.

Why does this problem occur

This issue is because the “add-apt-repository” command is part of the software-properties-common package and you need to install this package in order to install add-apt-repository.

How to install the required software

To install the necessary software on our server to fix the error with add-apt-repository, we first execute the command to update the OS:

apt update

Then we execute the command below to install software-properties-common. Accept the conditions and wait for it to be installed:

apt install software-properties-common

After you have installed software-properties-common, you must update the system with this command:

apt update

You can now conveniently use the add-apt-repository or apt-add-repository commands to add a PPA. For example, we will try to install the package below:

apt-add-repository ppa:ansible/ansible
apt list -a ansible
apt install ansible

As you can see, we have added the PPA of this software, and also successfully launched its installation.

Conclusion

In this tutorial, you learned how to use the add-apt-repositories command on Ubuntu or Debian to fix the “the repository not found” error.

You also gained an understanding of software repositories and package management, and the value they bring to maintaining your systems and keeping them at an optimal level.