YUM - Add a YUM repository
by
Jeremy Canfield |
Updated: June 02 2023
| YUM articles
There are two ways to add a repository to YUM.
- Add a .repo file to the /etc/yum.repos.d/ directory (preferred)
- Add a [repository] block to /etc/yum.conf
Let's say you want to add the EPEL repository. Typically, this would be done by issuing the following command.
yum install epel-release
If using an Amazon EC2 instance, you might need to go with this command.
sudo amazon-linux-extras install epel
This command will create the epel.repo file in the /etc/yum.repos.d directory.
~]$ ll /etc/yum.repos.d/
-rw-r--r--. 1 root root 1664 Apr 7 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr 7 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Apr 7 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Apr 7 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Apr 7 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr 7 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 7577 Apr 7 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 Apr 7 2020 CentOS-x86_64-kernel.repo
-rw-r--r-- 1 root root 1050 Oct 31 2020 epel.repo
-rw-r--r-- 1 root root 1149 Oct 31 2020 epel-testing.repo
Alternatively, you could manually create a repo file, such as foo.repo.
touch /etc/yum.repos.d/foo.repo
And then add something like this to the repo file.
[foo]
name=foo repository
baseurl=http://www.example.com/foo
enabled=1
gpgcheck=0
Did you find this article helpful?
If so, consider buying me a coffee over at