How to Fix 'add-apt-repository command not found' on Ubuntu & Debian?


Introduction

Ubuntu and Debian users have often encountered the problem of not being able to find the 'add-apt-repository' command. The error message typically reads "Command 'add-apt-repository' not found, but can be installed with: sudo apt-get install software-properties-common". This error message may seem intimidating for new users, but it is easy to fix if you understand what is causing it.

The Importance of the add-apt-repository Command

Before we delve into fixing the problem, let's discuss why this command is essential for Ubuntu and Debian users. The add-apt-repository command allows you to easily install third-party repositories onto your system, which enables you to download and install packages that are not available in the official Ubuntu or Debian repositories. This command greatly enhances your system's functionality by allowing you to access a much broader range of software applications.

An Overview of the Solution

The solution to this problem is relatively straightforward, as mentioned in the error message itself. You need to install the Software Properties Common package via apt-get install software-properties-common command either by using sudo privileges or as a root user.

Additionally, if for some reason installing Software Properties Common does not work, there is also an alternative solution: manually adding the add-apt-repository script to your system's directory. In this article, we will cover both solutions in detail so that you can easily solve this issue on your Ubuntu or Debian system.

Understanding the Problem

What is add-apt-repository?

Add-apt-repository is a command that allows users to easily add external repositories to their Ubuntu or Debian distribution. These repositories can provide access to additional software packages or updates that are not available in the default software sources.

This command essentially adds a new repository address to the /etc/apt/sources.list file, which is then used by other package management tools such as apt-get and Synaptic.

Why is it not found?

The add-apt-repository command might not be found due to several reasons. Firstly, it may not be installed on your system. It's a part of the software-properties-common package, which may not be installed by default on some Ubuntu or Debian distributions.

Secondly, your system might have an outdated package cache, so it fails to locate the add-apt-repository command even though it's installed on your system. There could be errors in your sources.list file that prevents the command from working correctly.

How to check if it's installed?

To check if add-apt-repository is installed on your system, you can simply run the command in a terminal window. If you receive an error message stating "command not found", then you will need to install the software-properties-common package which includes this command.

You can do this by running "sudo apt-get install software-properties-common" and entering your password when prompted. Once installed successfully, you can test whether add-apt-repository works correctly by running "sudo add-apt-repository" again and verifying that there are no error messages returned.

Solution 1: Installing Software Properties Common

Explanation of Software Properties Common

Software Properties Common is a package that provides an abstraction of the used apt repositories. It includes a set of utilities that enable users to add and remove PPAs (Personal Package Archives) in Ubuntu and Debian-based distributions. With the software-properties-common package, you can easily add PPAs to your system using the add-apt-repository command.

Using this command, you can easily install third-party packages that are not available in the official Ubuntu or Debian repositories. This is particularly useful when you need to install software packages that are not available in your default repository or require an updated version.

How to install Software Properties Common?

To install Software Properties Common on Ubuntu or Debian, open a terminal window and run the following command −

sudo apt-get update sudo apt-get install software-properties-common 

This will update your system's package list and then proceed with installing the software-properties-common package. After installation, you should be able to access the add-apt-repository command without any issues.

Testing if add-apt-repository works

To test if add-apt-repository works correctly after installing Software Properties Common, simply run the following command −

sudo add-apt-repository universe 

This will attempt to add the universe repository to your system using the add-apt-repository command. If everything works correctly, you should see a message confirming that universe has been added successfully.

Installing Software Properties Common is an easy solution for fixing "add-apt-repository command not found" errors on Ubuntu & Debian-based systems. By following these simple steps outlined above, this error can be resolved quickly allowing users to continue adding third-party repositories with ease.

Solution 2: Manually Adding the Command

Explanation of manual adding

If the first solution did not work for you, you can manually add the "add-apt-repository" command to your system. This involves creating a symbolic link from /usr/bin/add-apt-repository to /usr/sbin/add-apt-repository.

Symbolic links are files that act as pointers to other files or directories in a Linux file system. By creating a symbolic link, you are essentially telling your system that when it looks for the "add-apt-repository" command in /usr/bin directory, it should instead look in /usr/sbin directory where the command is located.

How to manually add add-apt-repository command?

To manually add the "add-apt-repository" command, follow these steps −

  • Open a terminal window on your Ubuntu or Debian system.

  • Type "sudo ln -s /usr/sbin/add-apt-repository /usr/bin/add-apt-repository" and press Enter.

  • This will create a symbolic link from /usr/bin/add-apt-repository to /usr/sbin/add-apt-repository. After creating this symbolic link, you should be able to use "add-apt-repository" normally.

Testing if add-apt-repository works

To test if the second solution worked for you, try running any of the commands that require "add-apt-repository". For example, type "sudo apt-add-repository ppa:example/example" and press Enter. If there are no error messages and you are prompted with information about what is being added, then everything has been installed correctly and you have successfully fixed the problem of 'add-apt repository command not found' on your Ubuntu or Debian system.

It is recommended that you choose the first solution over the second, as it is a much simpler process and less prone to error. However, if you encounter issues with that method, manually adding the command can be an effective solution.

Conclusion

In this article, we have discussed two solutions for the "add-apt-repository command not found" error on Ubuntu & Debian. The first solution is to install Software Properties Common, which will automatically install add-apt-repository. The second solution is to manually add the command by creating a symbolic link from the python3 software-properties-common package to /usr/bin.

While encountering errors can be frustrating, it's important to understand how they occur and how to fix them. In this case, both solutions offer effective ways to solve the "add-apt-repository command not found" error on Ubuntu & Debian. Additionally, it's worth noting that keeping your system up-to-date with the latest software updates can help prevent issues like this from occurring in the first place.

We hope that this article has been helpful in resolving your issue and has provided you with a better understanding of how to troubleshoot similar problems in the future. Remember to always be patient when facing errors, as most issues do have a solution.

Updated on: 09-Jun-2023

18K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements