How to fix add-apt-repository: command not found

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to fix add-apt-repository: command not found.

add-apt-repository is a tool that allows you to manage your repositories on your Ubuntu machine.

add-apt-repository can be used to add or remove existing repositories from your machine.

If you try to use add-apt-repository without installing it first on your system, you will get the error "add-apt-repository command not found".

This error can be fixed easily, and you can fix it by following the steps below.

Step 1 - Check if apt-add-repository is installed

First thing that you need to do is checking if add-apt-repository is installed.

To do this, simply run the command below

sudo add-apt-repository

If apt-add-repository is not installed, you will get the error

sudo: add-apt-repository: command not found

So you can proceed to the next step, to install add-apt-repository.

Step 2 - Install add-apt-repository

add-apt-repository tool cannot be installed by its name, meaning you can't install it with sudo apt install add-apt-repository as this tool is part of software-properties-common package, which means in order to install add-apt-repository, you need to install software-properties-common package.

To install software-properties-common, you can do so by running the command below.

sudo apt install software-properties-common

Step 3 - Run apt-add-repository

software-properties-common should be now installed on your machine, and you should be able to use add-apt-repository.

As we explained earlier, apt-add-repository can be used to manage the repositories on your system.

To verify that add-apt-repository was installed correctly, and that is able to be used, simply run.

The command below will show you your current repositories on the sources.list

add-apt-repository -L

Conclusion

In this tutorial, you learned how to fix the error "add-apt-repository: command not found".

We encountered this error on Ubuntu 22.04, and we fixed it by installing the missing package software-properties-common that contains add-apt-repository package.