The add-apt-repository command is vital for managing software sources in Ubuntu and Debian-based distributions, allowing users to add external repositories for software not in the default repositories. However, it might not be pre-installed in some variations like Raspberry Pi OS, leading to the “sudo: add-apt-repository: command not found” error.

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

This command is included in the software-properties-common package. To resolve the “command not found” error, users need to install this package using apt. The software-properties-common package provides essential tools for managing software sources, making it indispensable for system administrators.

By installing software-properties-common, users can regain the ability to add repositories and manage software sources efficiently. The process involves updating package information, optionally upgrading installed packages, and installing the software-properties-common package.

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.