How To Add/Remove A Software Repository In Linux?

How To Add/Remove A Software Repository In Linux?

   

This post was last updated on August 3rd, 2020 at 02:56 pm

Software Repository

A software repository(also called ‘repo’) is the database of software packages stored on a remote server. The server also contains metadata of packages. Generally, these packages are retrieved by using a package manager in the local machine. When you install a distribution of Linux it comes with a pre-configured default repository to download the applications, but sometimes it is needed to download the software from a different source that is not listed in default repositories. In this case, first, you will have to add the repository into the system and then you can perform the installation process of software.

Ahead in this article, we will discuss adding and removing software repositories in different distributions of Linux.


Adding a repository in debian based systems

In debian based systems such as Ubuntu, Linux Mint, elementary OS, etc repositories are managed via sources.list file. And can be edited by using a single file that is /etc/apt/sources.list. Now follow the below steps to edit it –

1. Open this file by using a text editor

sudo nano /etc/apt/sources.list

2. To enable a repository, remove the hash sign which is given at the beginning of the repository URL

#deb cdrom:[Linux Mint 19.2 _Tina_ - Release amd64 20190729]/ bionic contrib main non-free

Change it to –

deb cdrom:[Linux Mint 19.2 _Tina_ - Release amd64 20190729]/ bionic contrib main non-free

3. Save the file
Now save the file in the nano text editor by pressing ctrl+o followed by return key or :wq(in command mode) followed by the return key if you are using a vi text editor.

You can also add a repository from the terminal, follow the below steps –

1. Open your terminal by pressing  ctrl+alt+t
2. Add a repository

sudo add-apt-repository repository_url

For example-

sudo add-apt-repository ppa:danielrichter2007/grub-customizer

and press enter

3. Now update the apt package index with

sudo apt update

The repository is now added to the system. You can install the software from the source.


Remove repository in Debian based systems

To remove a software repository from the debian based system put # (hash) at the beginning of repository URL –
1. Open /etc/apt/source.list with a text editor

sudo nano /etc/apt/source.list

To disable a repository add the # (hash) at the starting of the line

deb cdrom:[Linux Mint 19.2 _Tina_ - Release amd64 20190729]/ bionic contrib main non-free

change to

#deb cdrom:[Linux Mint 19.2 _Tina_ - Release amd64 20190729]/ bionic contrib main non-free

2. Now save the file and exit from the text editor.

To remove a repository from the terminal, use the following command –

sudo add-apt-repository -r repository_url

for example-

sudo add-apt-repository -r ppa:danielrichter2007/grub-customizer

Adding a repository in CentOS and Fedora

In CentOS and Fedora repositories are managed by .repo files. These are the text files that reside in /etc/yum.repos.d directory. To add a repository from the terminal in a distribution which uses yum package manager, follow the below steps –

1. Open the terminal by pressing ctrl+alt+t
2. Execute the following command into your terminal

yum-config-manager --add-repo repository_url

For example –

yum-config-manager --add-repo http://www.example.com/example.repo

To enable the repository use –

yum-config-manager --enable repository_url

To add repository in fedora use –

dnf config-manger --add-repo repository_url

For example –

dnf config-manager --add-repo /etc/yum.repos.d/fedora_extras.repo

To enable the repository use –

dnf config-manager --set-enabled fedora-extras

Remove the software repository from CentOS and Fedora

You can remove a software repository from the CentOS and Fedora in the following ways –

1. Open the file /etc/yum.repos.d/repository_name.repo in CentOS. Or /etc/yum.repos.d/fedora_extras.repo in fedora by using a text editor and change enabled=1 to enabled=0 and then save it and exit from the editor.

2. Or you can delete the .repo file from the /etc/yum.repos.d directory. To delete .repo file use the following commands –

In CentOS use –

sudo rm /etc/yum.repos.d/repository_name.repo

In Fedora use –

sudo rm /etc/yum.repos.d/fedora_extras.repo

3. Or use the following commands to disable a repository from the terminal-

To disable a repository in CentOS use –

yum-config-manager --disable repository_name

To disable the repository in Fedora use –

dnf config-manager --set-disabled fedora-extras

I hope this will give you a basic understanding of using a software repository in Linux. If you still have any queries regarding this you can write us in comments.

Previous How To Change Default Settings Of Grub Bootloader?
Next Ukuu v19.10

About author

You might also like

Linux Topics 0 Comments

How To Install And Configure Fish Shell In Ubuntu 20.04 LTS?

This post was last updated on August 1st, 2020 at 10:33 amIn Unix-like operating systems such as Linux, a shell is a program that interprets the command, executes, takes input(s),

Linux Topics 0 Comments

How to Configure vncserver in Fedora Linux

This post was last updated on November 6th, 2016 at 12:32 amVnc server and vnc viewer is used to Remote Access in most of the Linux machines like Fedora, RHEL,

Linux Topics 0 Comments

How To Kill A Running Process In Linux/Unix?

This post was last updated on August 1st, 2020 at 12:44 pmIn Linux, a process is an instance of a program that is running on a computer. When a program

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply