Solved "sudo: add-apt-repository: command not found"


In this article, we will see how to solve add-apt-repository: command not found error. add-apt-repository is a free and open source utility to add PPA repository on Ubuntu/Debian based systems. Sometimes it is possible that when you try to add a PPA repo to download and install a package from it, you might end up getting add-apt-repository: command not found error on the output. Something like this happened to me as well when I tried adding ppa:unit193/encryption repo on my Ubuntu 22.04 LTS system. This can usually happen due to several reasons. Here we will see all the possible reasons and solutions that you may try to deal with this error.


Solved "sudo: add-apt-repository: command not found"

Solved "sudo: add-apt-repository: command not found"

Also Read: 20 dig command examples in Linux (Cheat Sheet)

As I was explaining, when I tried to add ppa:unit193/encryption repository using sudo add-apt-repository ppa:unit193/encryption -y command on my Ubuntu 22.04 LTS system then I noticed sudo: add-apt-repository: command not found error on the output as shown below. For you, it may be different repo on some other Ubuntu/Debian system.

cyberithub@ubuntu:~$ sudo add-apt-repository ppa:unit193/encryption -y
[sudo] password for cyberithub:
sudo: add-apt-repository: command not found

While the above error could occur due to several reasons but most of the time it occurs due to unavailability of add-apt-repository utility on your system. So to fix the above error, you have to install software-properties-common package on your system by using sudo apt install software-properties-common command as shown below. This will download and install the package from default Ubuntu repo along with all its dependencies.

cyberithub@ubuntu:~$ sudo apt install software-properties-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
python3-distro-info python3-httplib2 python3-jeepney python3-keyring python3-launchpadlib python3-lazr.restfulclient python3-lazr.uri python3-pyparsing
python3-secretstorage python3-software-properties python3-wadllib unattended-upgrades
Suggested packages:
libkf5wallet-bin python3-keyrings.alt python3-testresources python-pyparsing-doc python-secretstorage-doc bsd-mailx default-mta | mail-transport-agent
The following NEW packages will be installed:
python3-distro-info python3-httplib2 python3-jeepney python3-keyring python3-launchpadlib python3-lazr.restfulclient python3-lazr.uri python3-pyparsing
python3-secretstorage python3-software-properties python3-wadllib software-properties-common unattended-upgrades
0 upgraded, 13 newly installed, 0 to remove and 2 not upgraded.
Need to get 504 kB of archives.
After this operation, 4,174 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 jammy-updates/main amd64 python3-distro-info all 1.1ubuntu0.1 [6,952 B]
Get:2 jammy/main amd64 python3-pyparsing all 2.4.7-1 [61.4 kB]
Get:3 jammy/main amd64 python3-httplib2 all 0.20.2-2 [30.4 kB]
Get:4 jammy/main amd64 python3-jeepney all 0.7.1-3 [36.8 kB]
Get:5 jammy/main amd64 python3-secretstorage all 3.3.1-1 [13.2 kB]
Get:6 jammy/main amd64 python3-keyring all 23.5.0-1 [35.7 kB]
Get:7 jammy/main amd64 python3-lazr.uri all 1.0.6-2 [14.4 kB]
Get:8 jammy/main amd64 python3-wadllib all 1.3.6-1 [36.4 kB]
Get:9 jammy/main amd64 python3-lazr.restfulclient all 0.14.4-1 [51.2 kB]
Get:10 jammy/main amd64 python3-launchpadlib all 1.10.16-1 [125 kB]
Get:11 jammy-updates/main amd64 python3-software-properties all [28.8 kB]
Get:12 jammy-updates/main amd64 software-properties-common all [14.1 kB]
Get:13 jammy/main amd64 unattended-upgrades all 2.8ubuntu1 [49.4 kB]
Fetched 504 kB in 8s (62.6 kB/s)
Preconfiguring packages ...

You may be wondering why we are installing software-properties-common package instead of add-apt-repository utility. It is simply because add-apt-repository comes in packaged with software-properties-common so we have to install this package to get add-apt-repository utility.

After successful installation, if you now try to add PPA repo again then this time you will notice that you are able to add it successfully as shown below. This confirms that add-apt-repository is working as expected and hence the error is successfully resolved.

cyberithub@ubuntu:~$ sudo add-apt-repository ppa:unit193/encryption -y
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb jammy main'
VeraCrypt - Open source disk encryption with strong security for the Paranoid, based on TrueCrypt.

Debian and Rasbian builds:
More info:
Adding repository.
Adding deb entry to /etc/apt/sources.list.d/unit193-ubuntu-encryption-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/unit193-ubuntu-encryption-jammy.list
Adding key to /etc/apt/trusted.gpg.d/unit193-ubuntu-encryption.gpg with fingerprint 3BFB8E06536B8753AC58A4A303647209B58A653A
Hit:1 stable InRelease
Hit:2 jammy-security InRelease
Hit:3 buster InRelease
Hit:4 jammy InRelease
Hit:5 jammy-updates InRelease
Hit:6 stable InRelease
Hit:7 jammy-backports InRelease
Get:8 jammy InRelease [23.8 kB]
Get:9 jammy/main amd64 Packages [620 B]
Get:10 jammy/main Translation-en [480 B]
Fetched 24.9 kB in 18s (1,351 B/s)
Reading package lists... Done

Sometimes it is also possible that even though you have installed add-apt-repository utility on your system, still you are getting the same error. This can usually happen when you installed the utility in some customized location instead of in system defined binary location such as /usr/bin. To solve this problem, you can add the customized location to PATH environment variable.

export PATH=$PATH:/path/to/add-apt-repository

It is however important to keep in mind that above changes are temporary and is local to current session only. To make the changes permanent, you have to add an entry in either ~/.profile or ~/.bashrc file. Then logout and login to the system to update the changes. This should solve your problem.

Leave a Comment