Solving "bash: add-apt-repository command not found" on Debian

This article looks at the "bash: add-apt-repository command not found" error encountered on Debian or Ubuntu, when adding a repository on the local machine with the "add-apt repository" command. I'll explain how to correct this error so that you can continue adding the deposit.

For example, this error may appear when you try to use this command to install Ansible.

sudo apt-add-repository ppa:ansible/ansible

Which returns an unexpected result:

bash: add-apt-repository: command not found

Here's how to resolve this error on Debian or Ubuntu. As you'll see, it's quick and easy - all you need to do is install an additional package on your machine! Just follow the steps below.

1. Resolve add-apt repository error

First of all, open the terminal application on your Linux server, be it Ubuntu or Debian. To continue, you need an account with "sudo" access or the "root" superuser account.

Update the APT repositories and packages on your local machine:

sudo apt-get update
sudo apt-get upgrade

Next, install the software-properties-common package, which will enable you to correct the error directly, as it is used to add additional commands to the system, including this one for adding a PPA repository! Told you it'd be easy.

sudo apt-get install software-properties-common

From now on, check that the command is now available on your system by querying with the "type" command. Even if this is optional, it's always a good idea to check before using the command.

type apt-add-repository

That's all there is to it, the error has been corrected. Now you can use the "apt-add repository" command as you originally intended.

Solve "bash: add-apt-repository command not found" on Debian

2. The add-apt-repository command

I'd like to take this opportunity to give you a few more details on the add-apt-repository command and how it works. You should know that the " add-apt-repository "adds a repository to the /etc/apt/sources.list or /etc/apt/sources.list.dIt can also be used to delete an existing PPA.

It is used as follows:

add-apt-repository [options] ppa:nom_depot

The following options are available:

-h Show help message
-m Display debug info in Terminal (command line)
-r Delete specified repository (PPA)
-y : Automatically indicate "yes" to all questions
-u After adding the repository, update the package cache with the packages from this repository (this avoids the "apt-get update" command, a little trick you should know).
-k Use a custom URL for the key server, instead of the default one
-s : Allow source packages to be downloaded from the repository

Now you can solve the problem. "bash: add-apt-repository command not found" on your Debian or Ubuntu machine, and you'll also know a little more about how to use this command. If you've been able to solve your problem with this article, don't hesitate to leave a comment!

Resources

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *