The add-apt-repository command is essential for adding external repositories in Ubuntu and Debian-based systems. This command is part of the software-properties-common package, which might not be pre-installed in some distributions, leading to the “command not found” error.

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

To resolve this issue, you need to manually install the software-properties-common package. This package includes tools that allow you to manage software sources and add repositories as needed.

Once installed, the add-apt-repository command becomes available, enabling you to add repositories and manage software installations effectively on your system.

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

  1. Launch the 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

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.