Hello everyone In this Article we are going to learn to How to Configure YUM Repository in Linux in a very simple and easy step-by-step approach
How to Configure YUM Repository in Linux
yum is known as Yellowdog Updater, Modified (YUM). This utility is used to install updates remove the packages from the Linux.
The disadvantage of using rpm is that we cannot able to resolve the dependencies in the package manager but with the yum package manager we can resolve the dependencies.
How to configure yum locally?
First, we need to create the directory where we are going to put all the packages that are placed inside our DVD, Here my CentOS DVD is attached to my server.
In this case, We are making the directory name as local_repo
mkdir /local_repo
With the help of df -Th command we can see that our CentOS DVD Is attached to my server
Now we are going inside the CentOS DVD Directory
# cd /run/media/root/CentOS\ 7\ x86_64/
Now we are copying all the Directory and Files that are inside The DVD To the /local_repo directory.
# cp -rvf * /local_repo
After that, we are going inside the yum.repos.d directory where we need to create the file that contains the local_repo directory path. Right now there is nothing here
# cd /etc/yum.repos.d/
We are creating the file as example.repo here in this we are defining the Parameters that need to configure yum repository . Here
name – We are defining the comment here
baseurl = We are defining the path of the directory where we placed the CentOS DVD content
enabled = 1 = This means that we need to active this repository
gpgcheck = 0 = This means that we don’t have any key now if we have the key then we can define the path of the key soo that when we install the Package it will be verified with the key
[Example]
name = This is my First yum repository file
baseurl = file:///local_repo
enabled = 1
gpgcheck = 0
Now run yum clean all command
Now run yum repolist command to check everything is working
How to configure YUM Repository in a single command
We can also configure Yum repository using single command as shown below
# yum-config-manager --add-repo=file:///local_repo
Now when we go inside /etc/yum.repos.d directory we can see that the local_repo.repo file is created automatically
How to change the Global Yum repository file
We can also edit the Global yum configuration file so that if we don’t add the parameters in the above file that will be picked from the global file only.
Here we are editing the gpgcheck as 0 this means that if we don’t specify the parameter in the custom file then this will be picked from the global file
How to make Custom Repo Data
We can also create the Custom repo data in Linux,
This means that when we add or remove the packages in the Linux then the yum repository must be informed what we added or removed.
We are creating the directories as software/itrpm
# mkdir -p /software/itrpm
Now we are going inside the CentOS DVD Directory
# cd /run/media/root/CentOS\ 7\ x86_64/
Now we only need Package directory not all files and directory
# cd /Packages
Now we are copying the all data inside the Packages directory to the /software/itrpm directory.
# cp -rvf * /software/itrpm
Now we are going inside the /etc/yum.repos.d directory and we are creating the file as itrpm.repo,
Here we defined the baseurl as the /software directory
Now we are creating the repodata for the /software directory with the following command.
Please note that whenever we add or remove the Packages then we have to execute the command soo that this will update the yum repolist
# createrepo -v --update /software
Now when we go inside the /software directory we can see that the directory named as repodata is created
Now we need to execute # yum clean all command
Yum commands
Command to List all the packages
# yum list all
Command to List only Installed packages
# yum list installed
Command to Check weather the Particular Package is there or not,
Just add the package name with the list option in yum command
# yum list httpd
Command to get information of the Package
Just add the package name with the info option in yum command
# yum info httpd
Command to Install the Package
Just add the install option with the package name
# yum install httpd
Command to update the package
Just add the update option with the package name
# yum update httpd
Command to Install the package
Just add the install option with the package name and we are adding the -y option because this will not prompt the yes/no to install the dependency
# yum install httpd -y
Command to Remove the package
Just add the remove option with the package name, This will only remove the package their dependency will not remove
# yum remove httpd
Command to Remove the package With dependency
Just add the autoremove option with the package name
# yum autoremove httpd
How to check the logs of the yum command
First we need to go to the /var/log directory , Then execute the following command to get the logs
# tail -F yum.log
Suppose we want to install the web server and we don’t know the name of the package then we can add search all option in the yum command with the phase we want to search
# yum search all "web server"
Similarly if we want to install mail server and we don’t know the package name then we can do this same trick .
# yum search all "mail server"
Conclusion
If you want to learn Linux in the most simple language then please click on this link.
If you want to refer online manual for the yum command then click on this link
This is the complete knowledge of How to Configure the YUM Repository in Linux using the yum command if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on the Linux post.