How to create a yum repository file in Linux?

To create a yum repository file, you first need to create a .repo file and define the basic information and settings of the yum repository in it. Here is a simple format example of a .repo file.

  1. Create a new .repo file using an editor, for example, myrepo.repo.
vi /etc/yum.repos.d/myrepo.repo
  1. Add the following content to the .repo file:
[myrepo]
name=My Custom Yum Repository
baseurl=http://example.com/myrepo
enabled=1
gpgcheck=0

In the example above, [myrepo] is the name of the yum source, name is the description of the source, baseurl is the URL address of the yum source, enabled indicates whether the source is enabled (1 for enabled, 0 for disabled), gpgcheck indicates whether to check the signature of rpm packages.

  1. Save and exit the editor.
  2. Run the following command to update the yum repository:
yum makecache

You have now successfully created and set up a new yum repository file. You can use the yum command to install, update, and remove packages, as well as retrieve packages from your custom yum repository.

bannerAds