Ubuntu add-apt-repository command not found error and solution

Ian trying to run a command named ‘sudo add-apt-repository ppa:foo/bar‘ but getting the following error on screen:
     sudo: add-apt-repository: command not found
How do I fix this problem on Ubuntu Linux 14.04 or 16.04 or 18.04 or 20.4 LTS and Debian Linux server?

To manage the repositories that you install software from various PPA (Personal Package Archives). It allow you to upload Ubuntu source packages to be built and published as an apt repository by Launchpad. This page explains how to quickly fix the “add-apt-repository command not found” error on Ubuntu and Debian-based Linux distributions using the command line options.

Fix sudo: add-apt-repository: command not found

The package add-apt-repository is not installed on your server. Hence you get the error. In order to fix it try the following solutions.

Fix error on Ubuntu Linux 14.04/16.04/18.04/20.4 LTS or above

Simply install the following package on Ubuntu Linux version 14.04 LTS using the apt command/apt-get command:
sudo apt install software-properties-common

Solved add-apt-repository command not found’ Error on my Ubuntu 20.04 LTS server

Please note that we can not simply run the “apt install add-apt-repository” command as it comes from the software-properties-common package. However, we can search for command using the following syntax:
search for pkg to get rid of Ubuntu add-apt-repository command not error ##
sudo dpkg -S /usr/bin/add-apt-repository
## or ##
sudo apt-file search add-apt-repository

Sample outputs:
software-properties-common: /usr/bin/add-apt-repository
software-properties-common: /usr/share/man/man1/add-apt-repository.1.gz

Hence, we need to install the software-properties-common on Ubuntu to get rid of this error. See how to find the package that provides a file for more information.

Fix add-apt-repository: command not found error on older Ubuntu servers

If you are using Ubuntu Linux version 12.04 LTS or 12.10 or version 13.10 or older try the following apt-get command:
sudo apt-get install python-software-properties
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  ca-certificates gir1.2-glib-2.0 iso-codes libasn1-8-heimdal libcurl3-gnutls
  libdbus-glib-1-2 libgirepository-1.0-1 libglib2.0-0 libglib2.0-data
  libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
  libheimntlm0-heimdal libhx509-5-heimdal libidn11 libkrb5-26-heimdal
  libldap-2.4-2 libroken18-heimdal librtmp0 libsasl2-2 libsasl2-modules
  libsasl2-modules-db libwind0-heimdal libxml2 openssl python-apt-common
  python3-apt python3-dbus python3-gi python3-pycurl
  python3-software-properties sgml-base shared-mime-info unattended-upgrades
  xml-core xz-utils
Suggested packages:
  isoquery libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql
  libsasl2-modules-gssapi-mit libsasl2-modules-gssapi-heimdal python3-apt-dbg
  python-apt-doc python-dbus-doc python3-dbus-dbg libcurl4-gnutls-dev
  python3-pycurl-dbg sgml-base-doc bsd-mailx mail-transport-agent debhelper
The following NEW packages will be installed:
  ca-certificates gir1.2-glib-2.0 iso-codes libasn1-8-heimdal libcurl3-gnutls
  libdbus-glib-1-2 libgirepository-1.0-1 libglib2.0-0 libglib2.0-data
  libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
  libheimntlm0-heimdal libhx509-5-heimdal libidn11 libkrb5-26-heimdal
  libldap-2.4-2 libroken18-heimdal librtmp0 libsasl2-2 libsasl2-modules
  libsasl2-modules-db libwind0-heimdal libxml2 openssl python-apt-common
  python3-apt python3-dbus python3-gi python3-pycurl
  python3-software-properties sgml-base shared-mime-info
  software-properties-common unattended-upgrades xml-core xz-utils
0 upgraded, 37 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,173 kB of archives.
After this operation, 37.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libroken18-heimdal amd64 1.6~git20131207+dfsg-1ubuntu1.1 [40.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libasn1-8-heimdal amd64 1.6~git20131207+dfsg-1ubuntu1.1 [161 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty/main libidn11 amd64 1.28-1ubuntu2 [93.0 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libhcrypto4-heimdal amd64 1.6~git20131207+dfsg-1ubuntu1.1 [83.9 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libheimbase1-heimdal amd64 1.6~git20131207+dfsg-1ubuntu1.1 [28.9 kB]
Get:6 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libwind0-heimdal amd64 1.6~git20131207+dfsg-1ubuntu1.1 [47.8 kB]
....
..
...
Setting up iso-codes (3.52-1) ...
Setting up libglib2.0-data (2.40.2-0ubuntu1) ...
Setting up libsasl2-modules:amd64 (2.1.25.dfsg1-17build1) ...
Setting up python-apt-common (0.9.3.5ubuntu2) ...
Setting up python3-apt (0.9.3.5ubuntu2) ...
Setting up python3-dbus (1.2.0-2build2) ...
Setting up python3-gi (3.12.0-1ubuntu1) ...
Setting up shared-mime-info (1.2-0ubuntu3) ...
Setting up xml-core (0.13+nmu2) ...
Setting up python3-pycurl (7.19.3-0ubuntu3) ...
Setting up xz-utils (5.1.1alpha+20120614-2ubuntu2) ...
update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode
Setting up unattended-upgrades (0.82.1ubuntu2.4) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up python3-software-properties (0.92.37.7) ...
Setting up software-properties-common (0.92.37.7) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for ca-certificates (20141019ubuntu0.14.04.1) ...
Updating certificates in /etc/ssl/certs... 173 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...

Verification

Now you can use the following command to configure PPA:
$ sudo add-apt-repository ppa:foo/bar

sudo apt update
sudo apt install bar
The add-apt-repository is nothing but a script. It adds an external APT repository to either /etc/apt/sources.list or a file in /etc/apt/sources.list.d/. It can also remove an already existing repository using the following syntax:
sudo add-apt-repository --remove ppa:name/here

Getting help

Run the following simple command:
add-apt-repository --help
Where,

  • -h : Show help message and exit
  • -m : Print a lot of debug information to the command line
  • -r : Remove the specified repository
  • -y : Assume yes to all queries
  • -u : After adding the repository, update the package cache with packages from this repository (avoids need to apt-get update)
  • -k : Use a custom keyserver URL instead of the default
  • -s : Allow downloading of the source packages from the repository

Conclusion

You learned how to fix an error ‘add-apt-repository: command not found’ on Ubuntu and Debian based systems. See apt-get(8) man page for more info here.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Comments on this entry are closed.

  • 🐧 Vivek Gite Apr 8, 2020 @ 21:02

    Still have a question or problem with this error? Post it on the forum thread here and will sort it out for you.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.