How to Add Repository in Ubuntu? [3 Simple Methods]

You can use the following methods to add a repository in Ubuntu:

  1. Using the command line: run sudo apt-add-repository <repository_name>
  2. Editing the sources.list file: Add the “repository URL” and save the file.
  3. From Software & Updates: Go to Other Software, add the “repository URL”, click Add Source, and finally click Close.

Availability and Accessibility to extensive software packages are two of the prime attributes coming with Linux distributions such as Ubuntu. On top of that, repositories are the stockpile of those software packages and the effortless availing of software starts with learning how to add a repository. This article discusses an in-depth analysis of 3 methods of how to add repository in Ubuntu. It discusses the process of adding PPA repositories to Ubuntu including mentioning the addition of APT repositories.

Process Flow Chart to Add Repository in Ubuntu

Flowchart to add ubuntu repository [Distro Used Throughout the Tutorial: Ubuntu 22.04]

3 Easy Methods to Add Repository in Ubuntu

In Linux, adding repositories for availing the use of software packages is a fundamental operation that involves straightforward methods with easy-to-follow steps.

This section discusses 3 methods to add a repository in Ubuntu. It will mention the methods using the command line, and editing the sources.list file for adding repositories. Furthermore, it will shed light on adding a repository from the application Software & Updates advocating the friendly GUI-based approach.

Method 01: Using the Command Line

The CLI (Command Line Interface) lets you add a new repository with a few steps just by using the apt-add-repository command within the command line. Here’s how:

  1. First, open the Ubuntu terminal.
  2. Then, run the command mentioned below:
    sudo apt-add-repository deb https ://ppa.launchpadcontent.net /mozillateam/ppa/ubuntu/ jammy main
    EXPLANATION
    • sudo: Grants root privileges.
    • apt-add-repository: Adds a new repository to the system.
    • deb: Points out repository type in Debian-based distro such as Ubuntu.
    • https ://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu/: Repository web address.
    • jammy: Codename for Ubuntu 22.04.
    • main: Indicates that the software packages are within the main repository.
    the new repository is added using commandIn the above image, you see that I am adding a new repository to the system.
  3. After that, run the command below to update system repository list:
    sudo apt update
    EXPLANATION
    • sudo: Grants root privileges.
    • apt: The package management tool.
    • update: Action updating the system repository index.
    repository list updated after adding repository in ubuntuHere, you see that I have updated my system with the latest repository information.
  4. Finally, run this command to display the added repository for verification:
    apt-add-repository --list
    EXPLANATION
    • apt-add-repository: Adds/deletes a repository.
    • – -list: Enlists all the available system repositories.

    listing new repository after adding repository in ubuntuSo, in the snapshot above, you see that I have added a new repository to the existing list without any issues.

Method 02: By Manually Editing the “sources.list” File

The system directory named (/etc/apt/sources.list.d/) is responsible for repository storage. So, you can insert any new repository by simply modifying the sources.list file by accessing it via text editors such as nano. Here’s a step-by-step guide on how to add a repository by editing the “sources.list” file:

  1. First Run the below command in the prompt:
    nano /etc/apt/sources.list
    EXPLANATION
    • nano: Opens a file in the nano text editor.
    • /etc/apt/sources.list: The configuration file to open for adding repository.

    list repo from nano for how to add repository in ubuntuHere, you can see the current repositories from the source file.
  2. Now, type the repository address you want to add to the system:new repo URL is added in sources.list file to add repository in ubuntu In the image, for example, I have added the repository named deb http://repo.tld/ubuntu distro component.

  3. After that, press CTRL+S to save the file and then press CTRL+X to exit.
  4. Finally, after updating the system using sudo apt update, list repositories to reflect on the changes:
    apt-add-repository --list

    the new repository added successfully using nanoIn the screenshot above, you can notice that I have added a new repository with ease from the sources.list file.

Method 03: Add Repository from Software & Updates

You can use the GUI (Graphical User Interface) to add a new repository to the system which only requires the use of the “Software & Updates” application and it is the most beginner-friendly method to add repository providing a visual interface. Here’s how to add repository in Ubuntu via Software & Updates:

  1. Go to Software & Updates.software and updates GUI to show how to add repository in ubuntu
  2. Now, redirect to Other Software, click Add, provide the repository URL, and click Add Source.the repository url is added in the apt line segment
  3. At this point, enter the user password for authentication.enter password for authenticating the add repository in ubuntu
  4. Click on Reload to update the software cache.pressing reload to update repository list
  5. Finally, go to the Other Software tab to see the changes in the repository list.the repository list displayed via GUI other software tab So, in the above image, you see I have successfully added a new repository using GUI.

Add PPA repository in Ubuntu

The PPA (Personal Package Archive) repository is a subset of apt repositories that supply additional software resources for Debian-based systems like Ubuntu. These are widely used software versions with packages not usually found in the official ones. It allows users to upload Ubuntu source packages to be built and published as an apt repository hosted by Launchpad.

Here’s a step-by-step guide on how to add a PPA repository using the command line:

  1.   Run the apt-add-repository command followed by the name of the PPA repository. For example, to add Jonathan F’s PPA containing “FFmpeg version 4X”, run:
    sudo apt-add-repository ppa:jonathonf/ffmpeg-4 

    add ppa repositoryIn the above, the apt-add-repository command adds a new PPA repository jonathanf.

  2.   Now, after repository addition, run the following command and update the system repository index:
    sudo apt update

    update repo indexFinally, in the following, running the apt-add-repository --list command shows that the PPA repository has been successfully added.PPA repository added with success

Adding a PPA Repository Using GUI

Apart from adding a repository using the terminal, the GUI lets users add a PPA repository in Ubuntu easily from the Software & Updates application. Here’s how to add a PPA repository via “Software & Updates”:

  1. First, Go to the Other Software option from the Software & Updates application. Then  Click Add, provide the repository URL, and click Add Source.add PPA repo with GUI
  2. At this point, provide a user password for authentication.add user password to authenticate
  3. Finally, click the Reload button to update the system cache.reload to update cache after adding PPA repo

Conclusion

This article discusses 3 simple methods for how to add a repository in Ubuntu which is an active footstep in the realm of software repository configuration. It discusses adding repositories using the command line as well as using the graphical interface and by editing the sources.list configuration file. Furthermore, it mentions the addition of PPA repositories using the terminal and visual interface.  I hope this article aids your learning of repository management and takes you one step further in becoming a Linux power user.

People Also Ask

How to install a software package using the PPA repository in Ubuntu?

To install a software package after adding a PPA repository in Ubuntu using the sudo add-apt-repository <ppa_repository> command, you can run the command sudo apt install <package_name> to install the intended package using the PPA repository with all the dependencies.

What is a repository in Linux?

A Linux repository is a location where the information and metadata of software packages are stored for your OS to retrieve and use. It is used to install and update the software packages that you intend to utilize for different needs.

Can I add a repository in Ubuntu without using the apt-add-repository command?

Absolutely. To add a repository in Ubuntu without using the apt-add-repository command, run the command sudo nano /etc/apt/sources.list. This opens the source configuration file sources.list. Then go to the end of the file, add the repository URL you intend to add to the system, and save the file by pressing CTRL+S. Finally, exit the file with CTRL+X and update the system repository log running sudo apt update.

How many repositories are there in Ubuntu?

There are four main repositories in Ubuntu: Main, Universe, Multiverse, and Restricted. Some other Ubuntu repositories are the partner and third-party repositories.

Where are Linux repositories located?

The Linux repositories are located at the /etc/apt/sources.list.d/ directory in the main source.list file. However, you can create a new file in the same location with a .list extension.

Should I update after adding a repository in Ubuntu?

Yes. You should update the system after adding a new repository. This is due to making the system aware of the recent changes on the repository list and fetching the latest information. To update the system after adding a repository, run the command sudo apt update in the terminal.


Related Articles


<< Go Back to Repository Configuration in Linux | Package Management in Linux | Learn Linux Basics

Rate this post
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
icon linux
Md Masrur Ul Alam

Assalamu Alaikum, I’m Md Masrur Ul Alam, currently working as a Linux OS Content Developer Executive at SOFTEKO. I completed my Bachelor's degree in Electronics and Communication Engineering (ECE)from Khulna University of Engineering & Technology (KUET). With an inquisitive mind, I have always had a keen eye for Science and Technolgy based research and education. I strongly hope this entity leverages the success of my effort in developing engaging yet seasoned content on Linux and contributing to the wealth of technical knowledge. Read Full Bio

Leave a Comment