Introduction
The 'add-apt-repository command not found' error appears when adding a new software repository on Ubuntu and Debian-based distributions. The error indicates that the command and its base package are missing from the system.
The fix is straightforward and requires installing the appropriate package.
This tutorial shows how to resolve the 'add-apt-repository command not found' error on Ubuntu and Debian-based Linux distributions.
Prerequisites
- A user account with sudo privileges.
- Access to a terminal window/command line.
Fix add-apt-repository: command not found Error
To resolve the 'add-apt-repository: command not found error', follow the steps below:
1. Run the apt update
command in the terminal to update the APT repositories:
sudo apt update
Wait for the update to complete.
2. Install the software-properties-common package using the apt-get command:
sudo apt-get install software-properties-common
The add-apt-repository
command is in the software-properties-common package. Press y and Enter if prompted to continue the installation.
4. Update the APT repositories after installation:
sudo apt update
5. Verify the installation with the following command:
add-apt-repository --help
The output shows the help menu. If there are no errors, the installation was successful.
Note: The apt-add-repository
command is an alias for add-apt-repository
.
How to Add APT Repository in Ubuntu & Debian
The add-apt-repository
command is essential for adding packages that are not in the default APT repositories. Developers create and maintain these repositories and allow others to add them via URLs or PPAs. Since these are unofficial repositories, add them from trusted sources to avoid potential security threats.
To add an APT repository, follow the steps below:
1. Use the add-apt-repository
command to add an APT repository:
sudo add-apt-repository [repository_URL/PPA]
For example, to add the Wine repository to Ubuntu, use:
sudo add-apt-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ $(lsb_release -cs) main"
2. Refresh the package list with:
sudo apt update
3. Proceed to install the packages from the newly added repository.
Note: Wine is a program that helps run Windows programs on Linux. After adding the repository, follow our guide to install Wine on Ubuntu.
Conclusion
After reading this guide, you learned how to resolve the 'add-apt-repository command not found' error and use the add-apt-repositories
command in Ubuntu or Debian.
Follow our guides to solve other common package manager errors, such as "Could not get lock /var/lib/dpkg/lock Error on Ubuntu" or "Sub-process /usr/bin/dpkg returned an error code (1)".