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

Introduction

The 'add-apt-repository command not found' Ubuntu error appears when trying to add a new software repository. This indicates that the add-apt-repository package is missing on your system.

This tutorial resolves the 'add-apt-repository command not found' error on Ubuntu and Debian-based Linux distributions.

Resolve add-apt-repository command not found error on Ubuntu.

Prerequisites

Steps to Resolve add-apt-repository: command not found error

Step 1: Update Local Ubuntu Repositories

Open a terminal window and enter the command to update repositories:

sudo apt update

The system confirms that the software repositories list on your local machine is updating.

example of apt-get update in ubuntu

Step 2: Install the software-properties-common Package

The add-apt-repository command is not a regular package that can be installed with apt on Ubuntu LTS / Debian. Instead, it’s a component of the software-properties-common package.

To get the add-apt-repository command, install the software-properties-common package:

sudo apt install software-properties-common

This is an example output after a successful installation:

sudo apt-get installing software properties package

Then, update the repository again with:

sudo apt update

Note: In Ubuntu 13.10 (and older), the add-apt-repository command is part of the Python software package. To install it, use the command:

sudo apt install python-software-properties

How to Add Apt Repository in Ubuntu & Debian

Certain software packages aren’t included in the default repositories. To make installing easier, developers created their own software repositories. This is when the add-apt-repository command is used.

For example, Wine is a popular package for running non-Linux software on a Linux system. But the latest version isn’t available through the default repositories.

To install the latest version of Wine on Ubuntu, you first need to grant access to the Wine repository:

sudo apt-add-repository ‘deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main’

Other software may be subject to additional licensing. Such as in the case of Debian, restrictive licensing may disqualify a package from being included in the default repositories. In these cases, the add-apt-repository command is the key to grant access to the software you want to install.

What is a Repository in Ubuntu

A software package is an application. In certain cases one package needs other packages (called dependencies) to run.

A package manager does the work of loading the software package you want. If there are any dependencies, the package manager installs those as well. Additionally, a package manager automatically keeps track of all installed software and updates.

A package manager works in tandem with a software repository. A repository is a database of many different software packages. By default, each Linux distribution grants access to a set of basic, default repositories.

In Ubuntu, the default repositories are:

  • Main – Free and open-source software from the Ubuntu developers
  • Universe – Free and open-source software from the Linux community
  • Restricted – Device drivers and other software under licensing from manufacturers
  • Multiverse – All other software under copyright or legal restriction

In Debian, the default repositories are:

  • Main – Free licensed software
  • Contrib – Free software that depends on non-free licensed software
  • Non-free – Software with restrictions on use and distribution

If you want to install a software package that’s not included in these default repositories, you need to add that repository to your package manager.

Conclusion

In this tutorial, you learned to use the add-apt-repositories command in Ubuntu or Debian to resolve the repository not found error.

You have also gained insight into software repositories and package management and the value they bring to maintain your systems and keep them at an optimum level.

Another common Ubuntu error is “Could not get lock /var/lib/dpkg/lock Error on Ubuntu” or “Sub-process /usr/bin/dpkg returned an error code (1)“, read our tutorials to resolve it.

Was this article helpful?
YesNo
Vladimir Kaplarevic
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.
Next you should read
How to use apt Package Manager on Ubuntu Linux
January 7, 2019

In Linux, special tools were developed for managing applications. Application software for Linux typically...
Read more
How to Use The APT-GET Command In Linux
May 6, 2019

Advanced Package Tool (APT) is a package management system used on Debian, Ubuntu and other Linux...
Read more
How to Fix sub-process /usr/bin/dpkg returned an error code (1) in Ubuntu
March 31, 2019

Dpkg is a tool used to install packages into a Debian, Ubuntu, Mint, Kali or deb based distributions. The...
Read more
PHP Error Reporting: How to Enable & Display All Errors / Warnings
August 6, 2019

If a script is not written correctly, or if something unusual happens, PHP can generate an error message. The...
Read more