In this article, we will see how to install add-apt-repository on Ubuntu 22.04 system. If you are looking to add PPA repositories in your system then there is no better utility than add-apt-repository
. It is very frequently used to add a new software repository to your system's software source list. Not only that it is also used to add source repositories, which contain the source code of software packages. add-apt-repository
is a free and open source tool available only through software-properties-common
package.
add-apt-repository helps simplifies the addition or removal of repo and completely eliminates the overhead of editing and managing /etc/apt/sources.list
file manually. It also eliminates the need of running sudo apt update
command manually to refresh the package databases as it automatically runs this command after addition of repo. Here we will see how to install add-apt-repository on Ubuntu 22.04 system in few easy steps. You may also want to check Solved: "sudo: add-apt-repository: command not found"
How to Install add-apt-repository on Ubuntu 22.04
Also Read: How to Install whois command on Ubuntu/Debian
Step 1: Prerequisites
a) You should have a running Ubuntu 22.04
Server.
b) You should have sudo
or root
access to run privileged commands.
c) You should have apt
or apt-get
utility available in your Server.
Step 2: Update Your Server
From time to time, Ubuntu releases all the bug fixes and security fixes to secure and safeguard systems from any vulnerabilities. It is mandatory to have them in your system by regularly looking for latest updates and install them by using sudo apt update && sudo apt upgrade
command as shown below.
itsfosslinux@ubuntu:~$ sudo apt update && sudo apt upgrade Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease Hit:2 https://artifacts.elastic.co/packages/8.x/apt stable InRelease Hit:3 http://in.archive.ubuntu.com/ubuntu jammy InRelease Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease Hit:5 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:6 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease Hit:7 https://ngrok-agent.s3.amazonaws.com buster InRelease Hit:8 https://ppa.launchpadcontent.net/unit193/encryption/ubuntu jammy InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done 2 packages can be upgraded. Run 'apt list --upgradable' to see them. Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: apparmor libapparmor1 2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 634 kB of archives. After this operation, 4,096 B of additional disk space will be used. Do you want to continue? [Y/n] Y .................................................
Step 3: Install add-apt-repository
Since add-apt-repository is available through software-properties-common package, you need to install this package from default Ubuntu repo to install add-apt-repository utility in your server. It can be easily downloaded and installed using either apt
or apt-get
package manager. You just have to run sudo apt install software-properties-common
or sudo apt-get install software-properties-common
command as shown below. This will download and install the package along with all its dependencies.
itsfosslinux@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 needrestart 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 0 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 ..........................................................
Step 4: Verify Installation
After successful installation, you can verify the installed files path by using dpkg -L software-properties-common
command as shown below.
itsfosslinux@ubuntu:~$ dpkg -L software-properties-common
/.
/etc
/etc/dbus-1
/etc/dbus-1/system.d
/etc/dbus-1/system.d/com.ubuntu.SoftwareProperties.conf
/usr
/usr/bin
/usr/bin/add-apt-repository
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/softwareproperties
/usr/lib/python3/dist-packages/softwareproperties/dbus
/usr/lib/python3/dist-packages/softwareproperties/dbus/SoftwarePropertiesDBus.py
/usr/lib/python3/dist-packages/softwareproperties/dbus/__init__.py
/usr/lib/software-properties
/usr/lib/software-properties/software-properties-dbus
/usr/share
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/add-apt-repository
/usr/share/dbus-1
/usr/share/dbus-1/system-services
...............................................
Step 5: Using add-apt-repository
Now that add-apt-repository is installed, let's use it to add a sample PPA repo ppa:libreoffice/ppa
by using sudo add-apt-repository ppa:libreoffice/ppa
command and see if it is working. As you can see from the output, repository added successfully. Hence it is confirmed that add-apt-repository
utility is working as expected.
itsfosslinux@ubuntu:~$ sudo add-apt-repository ppa:libreoffice/ppa PPA publishes dbgsym, you may need to include 'main/debug' component Repository: 'deb https://ppa.launchpadcontent.net/libreoffice/ppa/ubuntu/ jammy main' Description: LibreOffice test builds and backports This PPA will have what the Document Foundation calls "LibreOffice fresh", the latest release of the newest series (but no alpha/beta releases). There is a PPA dedicated to specific LibreOffice major series which support a range of older Ubuntu releases too: https://launchpad.net/~libreoffice/+archive/libreoffice-still ("Still") https://launchpad.net/~libreoffice/+archive/old-still ("Old Still") Alpha and beta releases of a new major releases and the first release candidate of minor updates can be found at: https://launchpad.net/~libreoffice/+archive/libreoffice-prereleases So much for other ppas. Please file bugs for these packages on launchpad as described in: https://lists.launchpad.net/libreoffice/msg00072.html This PPA might contain the release candidate that is assumed to become the final release even before it is declared so by the Document Foundation (e.g. usually release candidate 2 for minor updates). Most of the packages in this PPA have only experienced minor testing -- in fact it is the place to enable a wider audience to test packages before they are published into the distro proper. In general, this PPA is _not_ for the average user to install without a closer look (if it would be, its packages would be in the main repositories). OTOH, it is _way_ _better_ to use packages from this PPA than using the *.deb files that The Document Foundation provides upstream, which are intentionally build against a very old baseline for maximum compatibility. So, _if_ you want to be on the bleeding edge, do it here, not with upstream *.debs. In general, users are advised to take a look at the changelog for the details about a package. If there is a specific bug that is intended to be addressed by an update released into the PPA, you are encouraged to test, if the update solves that problem. Packages published after the distro release are mostly such specific fixes. Critical fixes will be SRUed into the main repositories after testing anyway (later, with more testing). To return to the LibreOffice version from the main archive, use ppa-purge. see: http://www.webupd8.org/2009/12/remove-ppa-repositories-via-command.html for details More info: https://launchpad.net/~libreoffice/+archive/ubuntu/ppa Adding repository. Press [ENTER] to continue or Ctrl-c to cancel. Adding deb entry to /etc/apt/sources.list.d/libreoffice-ubuntu-ppa-jammy.list Adding disabled deb-src entry to /etc/apt/sources.list.d/libreoffice-ubuntu-ppa-jammy.list Adding key to /etc/apt/trusted.gpg.d/libreoffice-ubuntu-ppa.gpg with fingerprint 36E81C9267FD1383FCC4490983FBA1751378B444 Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB] Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease Hit:3 https://artifacts.elastic.co/packages/8.x/apt stable InRelease Get:4 https://ppa.launchpadcontent.net/libreoffice/ppa/ubuntu jammy InRelease [23.8 kB] Hit:5 https://ppa.launchpadcontent.net/unit193/encryption/ubuntu jammy InRelease Hit:6 https://ngrok-agent.s3.amazonaws.com buster InRelease Hit:7 http://in.archive.ubuntu.com/ubuntu jammy InRelease Get:8 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB] Get:9 https://ppa.launchpadcontent.net/libreoffice/ppa/ubuntu jammy/main i386 Packages [24.0 kB] Hit:10 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease Get:11 https://ppa.launchpadcontent.net/libreoffice/ppa/ubuntu jammy/main amd64 Packages [33.1 kB] Get:12 https://ppa.launchpadcontent.net/libreoffice/ppa/ubuntu jammy/main Translation-en [13.3 kB] Fetched 323 kB in 5s (70.2 kB/s) Reading package lists... Done
Step 6: Check all available options
You can check all the options available with add-apt-repository
utility using add-apt-repository --help
command as shown below.
itsfosslinux@ubuntu:~$ add-apt-repository --help
usage: add-apt-repository [-h] [-d] [-r] [-s] [-c COMPONENT] [-p POCKET] [-y] [-n] [-l] [--dry-run] [-L] [-P PPA] [-C CLOUD] [-U URI]
[-S SOURCESLIST [SOURCESLIST ...]]
[line ...]
Only ONE of -P, -C, -U, -S, or old-style 'line' can be specified
positional arguments:
line sources.list line to add (deprecated)
options:
-h, --help show this help message and exit
-d, --debug Print debug
-r, --remove Disable repository
-s, --enable-source Allow downloading of the source packages from the repository
-c COMPONENT, --component COMPONENT
Components to use with the repository
-p POCKET, --pocket POCKET
Add entry for this pocket
-y, --yes Assume yes to all queries
-n, --no-update Do not update package cache after adding
-l, --login Login to Launchpad.
..............................................
Step 7: Uninstall add-apt-repository
Although it is not needed but in case if you would like to remove add-apt-repository
tool from your system then you can use sudo apt remove software-properties-common
command as shown below.
itsfosslinux@ubuntu:~$ sudo apt remove software-properties-common Reading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: 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 Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: software-properties-common 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 225 kB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 237593 files and directories currently installed.) Removing software-properties-common (0.99.22.8) ... Processing triggers for dbus (1.12.20-2ubuntu4.1) ... Processing triggers for man-db (2.10.2-1) ...