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 Some Important Commands Used In Linux/Unix
 

About author

You might also like

Linux Topics 0 Comments

How To Create A Shared Directory Between Host And Guest In KVM?

This post was last updated on August 1st, 2020 at 02:39 pmKVM or kernel-based virtual machine is a virtualization module of Linux kernel. It requires hardware with virtualization extensions such

How To 0 Comments

How To List The All Enabled Repositories In Linux?

This post was last updated on August 1st, 2020 at 01:28 pmA software repository is a database of software packages stored on a remote server. Generally, these packages are retrieved

Linux Topics 0 Comments

How To Use apt-mark Command In Linux?

On different distributions of Linux that use apt as the default package manager, apt-mark can be used to show, set, unset various settings of a package. The apt-mark can be

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply