How To Add/Remove A Software Repository In Linux?

How To Add/Remove A Software Repository In Linux?

Software Repository

A software repository also known as ‘repo’ in common language is the database of software packages stored on a remote server. It 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 we will have to add the repository into the system and then we can perform the installation process of software. Repositories may be for a particular program or it can be for an entire OS.

Adding a repository in debian based systems

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

1. Open the file by using a text editor
sudo nano /etc/apt/sources.list
2. Remove the hash sign which is at the beginning of the repository URL as given below

#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

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

You can also add the repository using terminal by the following commands –
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 return key

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

Remove repository in Debian based systems

To remove the repository from the debian based system again comment the uncommented repository URL
1. Open /etc/apt/source.list by using a text editor
sudo nano /etc/apt/source.list
now 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. Save the file and exit from the text editor.

You can also remove a repository from your terminal by using 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

1. Open the terminal by pressing ctrl+alt+t
2. Execute the following command into your terminal
yum-config-manager --add-repo repository_url(in centos and systems that uses yum config manager)

For example –
yum-config-manager --add-repo
yum-config-manager --enable exmaple(to enable the repository)

dnf config-manger --add-repo repository(in fedora)

For example – replace the repository with the path of .repo file
dnf config-manager --add-repo /etc/yum.repos.d/fedora_extras.repo
dnf config-manager --set-enabled fedora-extras(to enable the repository)

Remove the software repository from CentOS and Fedora

To remove the software repository in CentOS and Fedora use the following ways –

1. Open the file /etc/yum.repos.d/example.repo (in CentOS) or /etc/yum.repos.d/fedora_extras.repo(in Fedora) using a text editor and change enabled=1 to enabled=0 finally save it and exit from the editor.

2. Delete the .repo file from the /etc/yum.repos.ddirectory

sudo rm /etc/yum.repos.d/example.repo(in CentOS)

sudo rm /etc/yum.repos.d/fedora_extras.repo(in Fedora)

3. Or use the following commands in the terminal-
yum-config-manager --disable example (to disable a repository in CentOS)
dnf config-manager --set-disabled fedora-extras (to disable the repository in Fedora)

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

Uncategorized 0 Comments

How To Find A File Or Directory Quickly In Linux/Unix?

Searching a file manually in Linux or Unix can be a little bit challenging especially for new users. Linux/Unix provides various command-line tools that can be used to accomplish this

Uncategorized 1Comments

How To Change Bootscreen Logo In Linux Mint?

Bootscreen A bootscreen is a graphical representation of the boot porcess of an operating system. It can be scrolling boot messages in a console or virtual terminal. Or it can

Uncategorized 0 Comments

Some Important Commands Used In Linux/Unix

Command-line interface(CLI) is a way that allows users to interact with computer programs through commands. A user issues commands to a program which gets interpreted by a command-line interpreter. Most


No Comments Yet!

You can be first to comment this post!

Leave a Reply