Adding Repositories to APT and YUM in Linux

Updating APT repos
To add additional repo’s we need to update the /etc/apt/sources.list file. we can do this with a text editor:

sudo /etc/apt/sources.list

Here we’ll add the Opera repo into the file.

Once the file is updates, run:

sudo apt update

When we run the update, you’ll notice that there is a warning stating there is no public key.

This is because we do not have the public key installed for this repo so the server cannot verify if the remote server is legitimate or not. We can solve this by installing the key. Opera publish their key at https://deb.opera.com/archive.key – so to install it we use wget.

wget https://deb.opera.com/archive.key
sudo apt-key add archive.key

How do we know this worked? We can type:

apt-key list

We need to run apt-update one more time now we have our key installed.

apt update

Now that the repo is installed we could install opera using the command
apt install opera-stable

Updating YUM repos
In yum, the repo files are updates automatically when installing a package. The location of the repo files is /etc/yum.repos.d/

You could add additional repo files here and update them manually, but there really is no need.

One of the common repos to add for CentOS/RHEL is “EPEL”. It stands for “Extra Packages for Enterprise Linux”
yum install epel-release

Leave a Reply

Your email address will not be published. Required fields are marked *