[Fixed] bash: add-apt-repository: command not found

If you get the message “bash: add-apt-repository: command not found” while trying to use the add-apt-repository command in Ubuntu, it means that the software-properties-common package that has this command is not installed on your system.

In this tutorial, we will show you how to fix this error by installing the software-properties-common package.

Step 1: Update the Package List

Before installing any new packages, update your system repositories. This ensures that the package metadata is up to date and that the software-properties-common package is the most recent version. Use the following command to update the package list:

sudo apt update

Step 2: Install the software-properties-common Package

To install the software-properties-common package, run the following command:

sudo apt install software-properties-common

Step 3: Verify Installation

Once the installation is complete, you can verify that the package has been installed correctly by running the following command:

apt policy software-properties-common

You should see the following output:

Installed: (none)
  Candidate: 0.98.9.1
  Version table:
     0.98.9.1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Step 4: Using the add-apt-repository Command

You can now use the add-apt-repository command after installing the software-properties-common package. The add-apt-repository programme adds PPA (Personal Package Archives) repositories to your system that are not included in the default Ubuntu repositories.

To add a PPA, you can use the following syntax:

sudo add-apt-repository ppa:<ppa-name>

Replace <ppa-name> with the name of the PPA that you want to add. For example, if you want to add the PHP PPA, you would run the following command:

sudo add-apt-repository ppa:ondrej/php

Once you have added the PPA, you can run the apt update command to update the package list and make the new packages available for installation.

Conclusion

Installing the software-properties-common package will resolve the “bash: add-apt-repository: command not found” error. This package includes the command add-apt-repository which allows you to add PPA to your system.