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

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 packages containing the latest information on versions and metadata for configuration. The effortless availing of software starts with learning how to add a repository to your Ubuntu system which, is also, the scope of this article.

Key Takeaways

  • Learning to add repositories in Ubuntu.
  • Installing repositories in Ubuntu using CLI.
  • Attaching repositories in Ubuntu using GUI.

Requirements

Process Flow Chart

[Distro Used Throughout the Tutorial: Ubuntu 22.04]the flowchart of how to add repository in ubuntu

2 Easy Methods to Add Repositories in Ubuntu

To start the configuring of any software package, you must add a repository first for further seamless procedures. Here, in the following section, I will provide 2 methods for repository adding (using CLI and GUI) in Ubuntu.

You can read our Comparative Analysis of Methods to distinguish between these two methods and best pick one for your needs.

Method 01: Using CLI to Add Repositories in Ubuntu

The CLI (Command Line Interface) lets you add a new repository with a few steps.  Now, I will walk you through two different CLI-based approaches with hands-on illustrations.

A. Utilizing the apt-add-repository Command for Adding Repositories

You can add, update, or remove repositories using a very straightforward command named apt-add-repository. Now for addition, follow the below steps.

Steps to Follow >

➊ First, open the Ubuntu terminal.

➋ 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.

➌ After that, type the below command and hit ENTER for repository index updation.

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.

➍ Finally, run this command to display the added repository.

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.

B. Using the “Source File” for Adding Repositories

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 from the command line located in that directory.

Steps to Follow >

➊ First, press CTRL+ALT+T to open the terminal.

➋ Secondly, type the below command and hit ENTER.

nano /etc/apt/sources.list
EXPLANATION
  • nano: Adds/deletes a repository.
  • /etc/apt/sources.list: Opens the sources.list file in the nano text editor.

list repo from nano for how to add repository in ubuntuHere, you can see the current repositories from the source file.

➌ 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.

➍ After that, press CTRL+S to save the file and then press CTRL+X to exit.

➎ Finally, type the following command and hit the ENTER button.

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 02:  Using GUI to Add Repository in Ubuntu

You can use the GUI (Graphical User Interface) to add a new repository to the system which only requires a few easy steps.

Steps to Follow >

➊ Go to Software & Updates.software and updates GUI to show how to add repository in ubuntu➋ 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 ➌ At this point, enter the user password for authentication.enter password for authenticating the add repository in ubuntu➍ Click on Reload to update the software cache.pressing reload to update repository list

➎ 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.

Comparative Analysis of Methods

The following table represents the essence of the aforementioned methods as far as the repository insertion in Ubuntu is concerned.

Methods Pros Cons
Method 1
  • Fast and efficient.
  • Direct access to the source file.
  • Can be overwhelming for novice users.
  • Mistakes in writing commands lead to unwanted situations.
Method 2
  • Easy for beginners.
  • Prone to less error.
  • Hindrance to efficiency.
  • Slower process.

The selection of a method depends on several variables, such as a newbie will find GUI-based visual representations (method 2) easier to grasp. Conversely, the more experienced the user; the more predilection for the CLI- based approaches (method 1). Every technique is effective. They are now up to your personal preference.

Conclusion

In this article, I have tried to present you with the addition of Linux repositories by which you have already made your footsteps active in the realm of software repository configuration. Furthermore, I have significantly contributed to your path by providing pragmatic illustrations. Therefore, I hope to leverage your learning to become professional personnel in Linux software package management.

People Also Ask

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.

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?
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.

Related Articles


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

Rate this post
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