Creating YUM and DNF Repositories

redhat

As we all knows the yum and dnf commands are used to download and install software packages from software repositories configured in the node. In a centOS server, centos repositories will be configured by default. Similarly, in an RHEL system, redhat repositories will be configured. The EPEL repositories are used to install extra packages usually in redhat based systems.

Basics of DNF / YUM and its usage can be found here.

The command to list all repositories in a Redhat system is as follows:

[root@centos9vm ~]# dnf repolist all

===== ==
repo id repo name status
appstream             CentOS Stream 9 – AppStream enabled
appstream-source             CentOS Stream 9 – AppStream – Source disabled
baseos             CentOS Stream 9 – BaseOS enabled
baseos-source             CentOS Stream 9 – BaseOS – Source disabled
crb-debuginfo             CentOS Stream 9 – CRB – Debug disabled
epel             Extra Packages for Enterprise Linux 9 – x86_64 enabled
epel-cisco-openh264             Extra Packages for Enterprise Linux 9 openh264 (From Cisco) – x86_64 enabled

==== ==

As you can see some repositories are in enabled or disabled stage. This can be changed by using the following command

[root@centos9vm ~]# dnf repolist all | grep crb-debuginfo
crb-debuginfo          CentOS Stream 9 – CRB – Debug disabled

[root@centos9vm ~]# dnf config-manager –enable crb-debuginfo

[root@centos9vm ~]# dnf repolist all | grep crb-debuginfo
crb-debuginfo         CentOS Stream 9 – CRB – Debug enabled

===== ===

A new repository can be added by creating a “.repo” file in the folder “/etc/yum.repo.d

The same can be achieved by using the following command too:

[root@centos9vm ~]# dnf repolist all | grep fedora

[root@centos9vm ~]# dnf config-manager –add-repo “https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/”

Adding repo from: https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/

[root@centos9vm ~]# dnf repolist all | grep fedora

dl.fedoraproject.org_pub_epel_9_Everything_x86_64_       created by dnf confi enabled

[root@centos9vm ~]# cat /etc/yum.repos.d/dl.fedoraproject.org_pub_epel_9_Everything_x86_64_.repo
[dl.fedoraproject.org_pub_epel_9_Everything_x86_64_]

======= ==
name=created by dnf config-manager from https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/
baseurl=https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/
enabled=1

===== ===