For users, who would like to add a repository/PPA through add-apt-repository command may get the following error – Command ‘add-apt-repository’ not found. This happens because a package which contains the command-line utility (i.e. add-apt-repository) is not installed in their distribution.
There are two methods available to us for addition and removal of PPAs (i.e. Personal Package Archives) –
- Edit /etc/apt/sources.list file manually, or
- through add-apt-repository command.
In this article, we would discuss how to install the relevant package in our Ubuntu distribution. Don’t miss the additional info, if you want to get an idea of how to add the repository in our Ubuntu distribution. For detailed information, check the link as mentioned below in Additional info section. We would also like to add that following operations would require you to have superuser privileges. If you don’t have access to one, then contact your System Administrator for assistance.
Install software-properties-common package in Ubuntu distribution
To the fix the error we need to install the package software-properties-common. Its installation would require you to run the following in terminal –
sudo apt install software-properties-common
This will install the command-line utility add-apt-repository as provided with the package and will fix the error as well.
Additional info –
As discussed above there are two methods with which we could add the relevant PPAs/repository.
First, by editing source list file manually. All we have to do is open the file /etc/apt/sources.list with a text editor and append the file with relevant entries. For example, append the file to add any Linux distribution repository with –
deb http://<domain-name>/<distribution>/ component1 component2
Second, through the command-line utility add-apt-repository –
sudo add-apt-repository 'deb uri distribution [component] [..]' sudo add-apt-repository ppa:<ppa_name>
sudo add-apt-repository 'deb http://<domain-name>/<distribution>/ component1 component2'
Either of the methods discussed could be used to add a repository. Choose one which you comfortable with the most. For more about addition and removal of repositories in Ubuntu distribution, read the article here.
In conclusion, we have discussed how to fix the error – Command ‘add-apt-repository’ not found in Ubuntu distribution.