Explanation of the contents inside folder /etc/yum.repos.d
Solution 1:
Can someone please give me an overview in simple language of what are the contents inside yum.repos.d and how does it differ from the contents inside /etc/yum.conf [?]
Per this RedHat Article on YUM:
The configuration file for yum and related utilities is located at /etc/yum.conf. This file contains one mandatory [main] section, which allows you to set Yum options that have global effect, and can also contain one or more [repository] sections, which allow you to set repository-specific options.
So yum.conf is a basic set of instructions used by yum to run, which includes some repository information because it is literally required to use yum.
Regarding yum.repos.d in particular:
It is recommended to define individual repositories in new or existing .repo files in the /etc/yum.repos.d/ directory. The values you define in individual [repository] sections of the /etc/yum.conf file override values set in the [main] section.
In short, yum.repos.d contains "extra" repository information and only that. This information can potentially override whatever is in yum.conf.
This kind of separation of configuration information is common in Linux.
Many programs use text-based configuration files (which can be extremely large and hard to read or are intended to provide only a basic set of data to operate). As such, it is often considered desirable to sort out things that are more likely to need to be changed (such as repository data) from information that is less likely to need to be changed (how yum works by default).
I heard that we have to create a repository inside yum.repos.d directory. Why do we need to do that?
I am guessing you mean a repository configuration file (e.g. local.repo). If I am not mistaken, actual repositories can be potentially anywhere (taking into account connectivity and permissions).
Commands such as "yum install packagename" generally check for existing yum repository configuration files in yum.repos.d. It is a standard place to look for consistency.
Repository configuration files tell yum information about the actual repository (where package files are physically located). While there are a number of optional elements, each .repo file is required to have:
Repository ID - A one word unique repository ID e.g. [localrepo].
Name - A human readable name for the repository e.g. name=Awesome Local Repo
Baseurl - A URL to the repodata directory (where the actual files are kept). file://path, ftp://link, http://link, and https://link addresses are all valid options.
Enabled - Whether or not to enable the repository for use when performing updates and installs e.g. enabled=1 (1 - "use this repository", 0 - "do not use this repository").
Also does yum update command use those repositories ?
Any yum command to install or update will likely check them, yes.