Red Hat Server Administration: Yum Server Configuration
Red Hat Linux System Administration
Written to help IT professionals get an overview of yum server configuration
What is Linux System Administration?
Linux system administration is to manage the operations of a computer system. As most computing devices are powered by Linux, it is a really useful post.
People having the knowledge of Linux System Administration are tend to be in positions of technical support engineers and consultants in companies.
Yum (Yellowdog Update Modifier) is an open source management tool for Red Hat Packet Manager based Linux systems.
It allows users and administrators of a system to install, update, remove or search packages easily.
Since sometimes it’s a tiring process to resolve all the dependencies of a package, yum comes to help! Yum finds the links of dependencies a package requires and install them automatically while saving the time of users and administrators.
If a package gets an update by their developers and requires an additional library of dependency to work correctly, the yum server will find that dependency and install it at the time you update the latest packages.
Who should learn to configure a yum server?
Most of the times students going through Red Hat Administration classes are provided yum repository already configured by their instructors. So the students who are curious to learn about how the repository works and how is it configured by the lab instructor should start with this module and learn to set up a yum server utilized by all the computers in a lab environment or even a company environment where a hundreds of client computers can’t be connected to the Red Hat Servers to get latest updates and require a way to get it.
Prerequisites: The computers in your network should be connected to each other either through LAN or WLAN or NAT ( in case of virtual environment). Ping machines to check the same.
Configuring a Yum Server
Scenario: You’ve been appointed as a Linux System Administrator in a new startup where they have ten machines working on RHEL, and you’ve given a machine that you’ll utilize as the server to provide latest updates and software package installations to other client machines in the company. Since later that day you’re going to train your new workforce that has been using Windows for their lives the basics of Linux, it’s your responsibility to configure yum client on those client machines as well.
Since you can simply sit on your computer and write a custom script that sshes those machines and configures yum client to save you time. I’m going to show you about how you can configure yum client on one machine and then you can code the script up!
Now move up to the machine you wanna utilize as a server, we’re going to call it System 1 and other client machines are gonna be called as Desktop 1 to 10.
Fire up the terminal in your System 1 and type the following command:
Remember to have the hash sign before you begin, as configuring a server might require you to have root access on your machine. [[The $ sign represents a user account]]
The ‘df’ command will come up with a list of your drive partitions including the / or root partition where your system is stored. Just like the C:/ as the default system drive in Windows computers.
Look up for the disk that contains the image of your RHEL System. If no such partition appears than re-insert your removable drive through which you’ve installed the system or if it’s a dual booted system and the image file is in the other drive of your windows computer then visit that location and copy the file to your Desktop or anywhere you’d prefer.
Once you have that image file open it up and mount it to /mnt , to do that use the command:
# mount * /mnt
It’ll mount everything from your disk image to your /mnt partition, now go ahead and make a yum repository to check if everything went right.
# gedit /etc/yum.repos.d/[anyname].repo
You can use any text editor of your preference, gedit will open a graphical editor on your screen. If you can’t use GUI than go for vim editor by just replacing ‘gedit’ with ‘vim’ and then press ‘i’ to start editing the configuration file.
After opening the file,
Write up the following in your repo // remember to remove the braces and edit the name
Then save the configuration file and return to the terminal.
Once you’re back to the terminal run the command to check if your yum repository is properly configured or not.
# yum repolist
It’ll show you available amount of packages and will install some if your file is perfectly configured.
Now, since you’ve configured yum for your system, how about now sharing the same in the whole network for other systems to utilize?
We’ll create a simple web server to let others systems in our network utilize the repository and download updates over HTTP.
Since we’re all configured, it’s time to install some packages from our yum repository that’ll help us in completing our task. We’re going to install HTTPD packages from the yum repository that’ll help us in creating a web server and deliver files over a web browser.
# yum install httpd* // the * represents “everything” in Linux environment
This command will install all the required packages to create a web server. It’s time to get our hands dirty. Since we’ve already had a yum repository of our own, it’s a best practice to serve the copy of yum to the network, so in the case in future it fails to deliver the packages, we’ll have a backup to do that without the tough work of configuring the whole yum server back again.
Since we’re going to provide the packages over HTTP we need to add it to our firewall rules, it’s simple as that.
# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload
This will add HTTP in the firewall and reload the firewall to make changes persist even after a system reboot.
Now, we’ll make a directory called myserver inside our web server path where in future we’ll host websites for our clients. And we’ll copy all the content of /mnt in the new directory.
# mkdir /var/www/html/myserver
# cp -rf /mnt/* /var/www/html/myserver/ // the -rf option recursively and forcefully copies files
Now check your IP address using the following command:
It is similar to ipconfig in Windows and shows our IP address. If you don’t have an IP address set up already, use the following procedure:
Check for the name of your connection: # nmcli con show
In my case it is eth0 now, I’m going to give eth0 a local IP address of my network subnet
# nmcli con mod “eth0” ipv4.addresses “192.168.0.100/24” ipv4.method manual
// The method are of two types, manual and DHCP.
Now as we’re done with our IP, we’re going to update our Yum configuration file that we previously configured to check if our processes till now are perfectly fine. To do that we’ll re-open the file in a text editor of our preference and will edit the base url to the IP and the path of our yum repository that we made for our client machines to access.
# gedit /etc/yum.repos.d/[anyname].repo
And after editing it’ll look like this:
After saving the file, open the link in a web browser to check if everything is all right. It’ll show up some files that relate to your operating system.
At this point, your yum server is completely configured, and you can cross-check it by using the command yum repolist again to see if you’re still capable of fetching packages into your own machine.
Now it’s time to provide yum client or package manager to your client machines. To do that, simply copy your configuration file or manually add it into all other machines ((The names might change in [braces] and name=”here” but all other configuration should remain same.
Once you’re done adding repositories to your individual client systems, run the yum repolist command on each one of them to see if they’re capable of fetching repositories from your computer or not. If everything is all right, this practice is completed.
Do you like to write about your infosec knowledge, skills, opinions, or exploits?
Publish your original research, tutorials, articles, or other written content on Cybray's blog to be seen by thousands of infosec readers daily!