Ubuntu

How to Use “add-apt-repository” Command in Ubuntu 22.04

There are different methods to install the packages on Ubuntu through the default repository and deb packages, similarly, another common method is to add the PPA repository of the package in the Ubuntu and then install it using the apt package manager. This article is a guide on how to add and remove repositories on Ubuntu using the “add-apt-repository” command.

How to add the repository using the add-apt-repository command in Ubuntu

The general syntax of adding the repository in the Ubuntu 22.04 using the add-apt-command is:

$ add-apt-repository [options] repositor

Simply using the command, we can add the repository with some options (options are not mandatory to use) so now we will add the Blender PPA repository:

$ sudo add-apt-repository ppa:thomas-schiex/blender

We have seen that the PPA repository has been added successfully and then we will update the repository of the Ubuntu 22.04:

$ sudo apt update

The PPA repository of the Blender has been added and now the Blender package can be installed using the apt package manager.

How to remove the repository using the add-apt-repository command in Ubuntu

We can remove the repository from the list of the /etc/apt/sources.list.d using the add-apt-repository, as we are going to remove the above-added blender repository with its remove option:

$ sudo add-apt-repository --remove ppa:thomas-schiex/blender

How to fix sudo: add-apt-repository: command not found

While adding some PPA repositories, you may face such an error, “sudo : add-apt-repository: command not found” oas shown in the image below:

This error can be resolved by installing software-properties-common package using the command:

$ sudo apt install software-properties-common -y

The software-properties-common contain the tools that are used to add, manage, and remove the PPA repositories to Ubuntu.

Conclusion

To install packages from the PPA repository we use the command of the add-apt-repository. This command can add or remove the repositories in Ubuntu. In this write-up, usage of the add-apt-repository command has been explained with different examples of adding and removing the PPA repository.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.