add-apt-repository is a script to add external apt repositories in Ubuntu and other Debian-based Linux distribution. add-apt-repository is installed by default in Ubuntu and Debian distributions, but not in some variances such as Raspberry Pi OS. As such, you'll get the following error when trying to add a repository to your system;

$ sudo add-apt-repository ppa:ondrej/php
sudo: add-apt-repository: command not found

add-apt-repository is part of the software-properties-common package. You can install add-apt-repository to fix the add-apt-repository: command not found error by installing software-properties-common using apt from the terminal.

Steps to install add-apt-repository in Ubuntu or Debian:

  1. Launch terminal.
  2. Update package information for apt.
    $ sudo apt update
    [sudo] password for user: 
    Hit:1 http://ports.ubuntu.com/ubuntu-ports jammy InRelease
    Get:2 http://ports.ubuntu.com/ubuntu-ports jammy-updates InRelease [114 kB]
    Get:3 http://ports.ubuntu.com/ubuntu-ports jammy-backports InRelease [99.8 kB]
    Get:4 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease [110 kB]
    Get:5 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 Packages [520 kB]
    Get:6 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 DEP-11 Metadata [91.6 kB]
    Get:7 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 Packages [213 kB]
    Get:8 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 DEP-11 Metadata [146 kB]
    Get:9 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe arm64 DEP-11 Metadata [12.5 kB]
    Get:10 http://ports.ubuntu.com/ubuntu-ports jammy-security/main arm64 DEP-11 Metadata [11.4 kB]
    Get:11 http://ports.ubuntu.com/ubuntu-ports jammy-security/universe arm64 DEP-11 Metadata [10.1 kB]
    Fetched 1,329 kB in 10s (127 kB/s)                                           
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    8 packages can be upgraded. Run 'apt list --upgradable' to see them.
  3. Upgrade installed packages (optional).
    $ sudo apt upgrade --assume-yes
  4. Install software-properties-common using apt.
    $ sudo apt install --assume-yes software-properties-common
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following additional packages will be installed:
      python3-software-properties unattended-upgrades
    Suggested packages:
      bsd-mailx default-mta | mail-transport-agent needrestart
    The following NEW packages will be installed:
      python3-software-properties software-properties-common unattended-upgrades
    0 upgraded, 3 newly installed, 0 to remove and 8 not upgraded.
    Need to get 92.3 kB of archives.
    After this operation, 846 kB of additional disk space will be used.
    ##### snipped
Discuss the article:

Comment anonymously. Login not required.