I have written this quick tutorial to solve the “add apt repository command not found” error. It doesn’t matter if you use any of the latest Linux like Ubuntu/Debian/Kali/CentOS or Fedora. The major reason is either the add-apt-repository package is not installed or you are not using the right Linux distro.
If you will install this missing package, you are sorted. Following this article step by step will help you to get this issue resolved for sure.
Why do I get this “add apt repository command not found” error?
Generally, you get this error, if you don’t have the “add-apt-repository” package is not installed in your system. In Ubuntu, there are many ways to install packages in Linux, adding a repository and installing the package is one of them. Especially, in the case of third-party packages like Teamviewer.
If you are getting any similar error as below while adding the repository to install 3rd party packages, you are missing the add-apt-repository package.
- add-apt-repository command not found in Debian
- add-apt-repository command not found in Docker
- sudo: add-apt-repository: command not found
- add-apt-repository command not found in Kali Linux
- add-apt-repository command not found in Fedora
Let’s see how to fix this annoying error in each operating system.
Pre-requisite to fix add repository command issue
- Root or sudo privileges to install packages
- Ubuntu or similar Debian-based distro terminal or GUI access
- Internet connectivity
How to fix the “add apt repository command not found” error in Debian-based Linux distros
If you are using Debian based operating system like Ubuntu 21.04 or Ubuntu 22.04, Kubuntu, Lubuntu, Kali or Linux mint, follow these steps.
I will show the commands using Ubuntu 21.04 installed in my VMware workstation.
Step1 – Open the terminal in your Linux operating system
- Right-click on your desktop and select <open terminal> or press <Ctrl + ALT + T> on your keyboard
Step2 – Refresh the Ubuntu repository
This is the recommended step before installing any packages in Ubuntu.
$ sudo apt-get update or $ sudo update
Step3 – Add software-properties-common package
If you will try to install the add-apt-repository package using apt, you will get unable to locate the package error. Because the add-apt-repository package is not available as an individual package. It is part of the software-properties-common package.
To fix the add-apt-repository command not found error, you need to install the software-properties-common package.
Run the following command –
$ sudo apt install software-properties-common or # apt install software-properties-common
- # – commands need to run if you are a root user
- $ – If you are having sudo root privileges
Now the package will get installed for you. I have the latest version of the software-properties-common package installed, so no action has been taken by command.
Extra Tip –
Software-properties-common software provides an abstraction of the used apt repositories. It allows you to easily manage your distribution and independent software vendor software sources.
Step4- update the Ubuntu repository again
Once you installed the package, don’t forget to update the repository again.
$ sudo apt update
Step5- Run the add-apt-repository command to add PPAs
Now you can add any PPA to install your favourite package in Linux. For example to install libre office in your Linux, run the following command –
$ sudo add-apt-repository ppa:libreoffice/ppa
$ sudo apt-update
sudo apt install libreoffice
How to fix add-apt-repository command not found in Fedora
If you will try to run the above commands in Fedora, CentOS or any rpm-based distro. It will not fix your issue because commands are different for the rpm-based Linux operating systems.
Follow these steps, if you want to add third-party repositories to your RedHat, Fedora, CentOS, AlmaLinux or RockyLinux distros.
Step1 – Create a .repo file under /etc/yum.repos.d/ directory
First step is to create a file with .repo extension under /etc/yum.repos.d/ directory with root privileges. The file must contain at least following information.
[repository] name=repository_name baseurl=repository_url
Step2 – Add the newly created repository
dnf config-manager --add-repo repository
-file-path
Example:
dnf config-manager --add-repo /etc/yum.repos.d/fedora_extras.repo
Step3 – Enable the repository
dnf config-manager --set-enabled repository
Example –
dnf config-manager --set-enabled fedora-extras
In case of any issue, check out these fedora manuals for further information.
Frequently asked questions
How do I install the apt add repository?
You need to install the software-properties-common package to install the apt add repository package. Run the following command to install it.
$ sudo apt update
$ sudo apt install software-properties-common
Run repository refresh again.
$ sudo apt update
Why is the apt-get command not found?
There may be the following reason if you are getting the apt-get command not found error.
1. You are running the apt-get command on the non-Debian operating system. for example, if you will run the apt-get command on Redhat Linux or Fedora. It will not work and you will get the apt-get command not found error.
How do I fix sudo add-apt-repository command not found?
Follow these steps to fix sudo add-apt-repository command not found. These commands will run on Debian-based Linux distros only e.g. Ubuntu, Linux mint etc. Don’t run them on rpm-based distros.
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt update
What is sudo apt add repository?
sudo apt add repository command helps to add 3rd party or new repositories in Debian-based Linux operating system.
Why am I getting apt-add-repository: command not found error in Docker?
If you are getting apt add repository command not found error in Docker, make sure you add the following lines or command in the Docker file.
RUN apt-get update && \ apt-get install -y software-properties-common && \ apt update
Final note
So you learned how to solve the “add apt repository command not found” error in Linux. There are many other common errors like “Could-not-open-lock-file-var-lib-dpkg-lock-frontend” or sudo command not found error. You can read my tutorials to resolve these common errors in Linux.
Let me know if you still face any issues. I will try my best to help you.