Friday, 15 November 2013

Boot Process in Linux


                                                              Boot Process in Linux

Linux booting process is an essential part of every Linux user/administration which will give you a clear picture of how Linux Operating system works. In this post we will see what happens when a Linux OS boots i.e. after powering on the machine to the user login prompt. Below image will give you clear idea what will happen in Linux booting process.






A quick view of booting sequence:
Power on
CPU jumps to BIOS
BIOS runs POST
Finds first bootable device
Load and execute MBR
Load OS
User prompt

1. System Startup (BIOS)
This is the first stage is booting process.  When you power on/Restart your machine the power is supplied to SMPS (switched-mode power supply) which converts AC to DC. The DC power is supplied to all the devices connected to that machine such as Motherboard HDD's, CD/DVD-ROM, Mouse, keyboard etc. The most intelligent device in the computer is Processor(CPU), when supplied with power will start running its sequence operations stored in its memory. The first instruction it will run is to pass control to BIOS(Basic Input/Output System) to do POST(Power On Self Test). Once the control goes to BIOS it will take care of two things.
  • Run POST operation.
  • Selecting first Boot device.
Post operation:  The POST will check all hardware connected to system working correctly or not. 

Selecting Boot device: Once POST completes, it flushes from the memory, but the BIOS runtime services remain and it searches for devices for bootable disk, ( It will select the first boot device and gives back the control to Processor(CPU). Suppose if it does not find first boot device, it will check for next boot device, if not third and so on. If BIOS do not find any boot device it will alert user stating "No boot device found".) that order of preference defined in the complementary metal oxide semiconductor (CMOS) settings. A boot device can be a floppy disk, a CD-ROM, a partition on a hard disk, a device on the network, or even a USB flash memory stick. Once BIOS detects the bootable device then it executes the MBR (Master Boot Recorder).
2. Second Stage ( MBR) 

Once the BIOS gives control back to CPU, it will try to load MBR of the first boot device(We will consider it as HDD). MBR is a small part of Hard Disk with just a size of 512 Bytes, This MBR resides at the starting of HDD or end of HDD depending on manufacturer.

What is MBR? ( 1st Stage of the Boot Loader.)

MBR(Master Boot recorder) is a location on disk which have details about.
  • Primary boot loader code(This is of 446 Bytes)
  • Partition table information(64 Bytes)
  • Magic number(2 Bytes)
 Which will be equal to 512B (446+64+2)Bytes.

Primary Boot loader code: This code provides boot loader information and location details of actual boot loader code on the hard disk. This is helpful for CPU to load second stage of Boot loader.

Partition table: MBR contains 64 bytes of data which stores Partition table information such as what is the start and end of each partition, size of partition, type of partition(Whether it's a primary or extended etc). As we all know HDD support only 4 partitions, this is because of the limitation of its information in MBR. For a partition to represent in MBR, it requires 16 Bytes of space in it so at most we will get 4 partitions. to know more about this. ( http://www.linuxnix.com/2009/05/why-we-can-create-only-up-to-4-primary-partations.html)

Magic Number: The magic number service as validation check for MBR. If MBR gets corrupted this magic number is used to retrieve it. What to take backup of your MBR.
http://www.linuxnix.com/2009/11/how-to-take-the-backup-of-mbrmaster-boot-recorder.html

Now the MBR Loads in to RAM.
First Stage of the boot loader loads it-self in to memory, & finds the second stage boot loader, this is done by looking through the active partition table. When it finds an active partition, it scans the remaining partitions in the table to ensure that they are all inactive. After this verification the active partition’s boot record is reads from the RAM, and it will execute it.
In simple MBR loads the GRUB (Grand Unified Boot loader) from 1st sector of the 1st bootable partition(HDD).
3. Third stage Bootloader stage2 ( GRUB loader ).
Once the Bootloader stage 1 is completed and able to find the actual bootloader location, Stage 1 bootloader start second stage by loading Bootloader into memory. In this stage GRUB(Grand Unified Bootloader) which is located in the first 30 kilobytes of hard disk immediately following the MBR is loaded into RAM for reading its configuration and displays the GRUB boot menu (where the user can manually specify the boot parameters) to the user. GRUB loads the user-selected (or default) kernel into memory and passes control on to the kernel. If user do not select the OS, after a defined timeout GRUB will load the default kernel in the memory for starting it.
GRUB has the knowledge of the file system, but older Linux loader LILO didn’t understand filesystem.

4. Fourth Stage ( kernel) 

Once the control is given to kernel which is the central part of all your OS and act as a mediator of hardware and software components. Kernel once loaded into to RAM it always resides on RAM until the machine is shutdown. Once the Kernel starts its operations the first thing it do is executing INIT process.

During the boot of the kernel, the initial-RAM disk (initrd) that was loaded into memory by the stage 2 boot loader is copied into RAM and mounted. This initrd serves as a temporary root file system in RAM and allows the kernel to fully boot without having to mount any physical disks. Since the necessary modules needed to interface with peripherals can be part of the initrd, the kernel can be very small, but still support a large number of possible hardware configurations. After the kernel is booted, the root file system is pivoted (via pivot_root) where the initrd root file system is unmounted and the real root file system is mounted.

5. Stage (INIT)

init(initialization) process is the root/parent process of all the process which run under Linux/Unix. The first process it runs is a script at /etc/rc.d/rc.sysinit which check all the system properties, hardware, display, SElinux, load kernel modules, file system check, file system mounting etc. Based on the appropriate run-level, scripts are executed to start/stop various processes to run the system and make it functional. INIT process read /etc/inittab which is an initialization table which defines starting of system programs. INIT will start each run level one after the other and start executing scripts corresponds to that runlevel. Know more about runlevels here. The script information is stored in different folders in /etc/ folder
/etc/rc0.d/ –Contain Start/Kill scripts which should be run in Runlevel 0
/etc/rc1.d/ –Contain Start/Kill scripts which should be run in Runlevel 1
/etc/rc2.d/ –Contain Start/Kill scripts which should be run in Runlevel 2
/etc/rc3.d/ –Contain Start/Kill scripts which should be run in Runlevel 3
/etc/rc4.d/ –Contain Start/Kill scripts which should be run in Runlevel 4
/etc/rc5.d/ –Contain Start/Kill scripts which should be run in Runlevel 5
/etc/rc6.d/ –Contain Start/Kill scripts which should be run in Runlevel 6
Once the initialization process completes mandatory run level and reach to default runlevel set in /etc/inittab, init process run one more file /etc/rc.local which are the last commands run in initialization process or even booting process. Once everything is completed the control is given back to the kernel.
6. Stage ( User Prompt )
This is actually not part of booting process but thought of including it here for better understating. Once the Kernel get the control it start multiple instances of "getty" which waits for console logins which spawn one's user shell process and gives you user prompt to login.

Iptables in Linux



                                                                  Iptables

Linux comes with a host based firewall called Netfilter. Netfilter is a host-based firewall for Linux operating systems. It is included as part of the Linux distribution and it is activated by default. This firewall is controlled by the program called iptables. Netfilter filtering take place at the kernel level, before a program can even process the data from the network packet.

Iptables Config File

The default config files for RHEL / CentOS / Fedora Linux are:

/etc/sysconfig/iptables - The system scripts that activate the firewall by reading this file.

Task: Display Default Rules

Types the following command.

# iptables --line-numbers -n -L

Turn On Firewall

Type the following two commands to turn on firewall

chkconfig iptables on
service iptables start
# restart the firewall
service iptables restart
# stop the firewall
service iptables stop

Understanding Firewall

There are total 4 chains:

INPUT - The default chain is used for packets addressed to the system. Use this to open or close incoming ports (such as 80,25, and 110 etc) and ip addresses / subnet (such as 202.54.1.20/29).

OUTPUT - The default chain is used when packets are generating from the system. Use this open or close outgoing ports and ip addresses / subnets.

FORWARD - The default chains is used when packets send through another interface. Usually used when you setup Linux as router. For example, eth0 connected to ADSL/Cable modem and eth1 is connected to local LAN. Use FORWARD chain to send and receive traffic from LAN to the Internet.

RH-Firewall-1-INPUT - This is a user-defined custom chain. It is used by the INPUT, OUTPUT and FORWARD chains.

Packet Matching Rules
Each packet starts at the first rule in the chain .
A packet proceeds until it matches a rule.
If a match found, then control will jump to the specified target (such as REJECT, ACCEPT, DROP).

Target Meanings
The target ACCEPT means allow packet.
The target REJECT means to drop the packet and send an error message to remote host.
The target DROP means drop the packet and do not send an error message to remote host or sending host.

Open Port

To open port 80 (Http server) add the following before COMMIT line:

-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 80 -j ACCEPT

To open port 53 (DNS Server) add the following before COMMIT line:

-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -m udp -p tcp --dport 53 -j ACCEPT

To open port 443 (Https server) add the following before COMMIT line:

-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 443 -j ACCEPT

To open port 25 (smtp server) add the following before COMMIT line:

-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 25 -j ACCEPT

Only allow SSH traffic From 192.168.1.0/24

-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT 

Enable Printing Access For 192.168.1.0/24

-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -p tcp -m tcp --dport 631 -j ACCEPT

Allow Legitimate NTP Clients to Access the Server


-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 123 -j ACCEPT

Open FTP Port 21 (FTP)


-A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 21 -j ACC



more details





Friday, 8 November 2013

How to install Gnome Desktop on Rhel 6


                               How to install Gnome Desktop in Rhel6 manually

If you using text login and now want to switch Graphical login then follow this steps.

1. First go to root
# su -

2. Now install X Window System and a graphical desktop environment. For example, to install the GNOME desktop environment, use this command:

# yum groupinstall "X Window System" Desktop

To install the KDE desktop environment, use:

# yum groupinstall "X Window System" "KDE Desktop"

3. Now change the run level to edit the /etc/inittab file:

# vi /etc/inittab

Find the line that includes the text initdefault. Change the numeral 3 to 5.

4 . Now run reboot system.

# reboot 

Friday, 21 June 2013

How to format pendrive in linux command line



                            How to format pendrive in linux command line

#First got to superuser mode and run the mention command.
1. root@linux~# su - root

#That will show all the volume of your hard disk.
2. root@linux~# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1   976773167   488386583+  ee  GPT
Partition 1 does not start on physical sector boundary.

Disk /dev/sdc: 4010 MB, 4010803200 bytes
255 heads, 63 sectors/track, 487 cylinders, total 7833600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000fc03

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *        2048     7833599     3915776    c  W95 FAT32 (LBA)

In my system the usb drive is /dev/shc1

# umount /dev/sdc1
3. root@linux~# umount /dev/sdc1

# After you can format this pendrive which file system you want. I am going to format my pendrive with fat32 filesystem.
4. mkfs.vfat /dev/sdc1




Friday, 31 May 2013

How to configure openldap in RHel5

                     
                                          How to configure openldap Server on RHEL5

First install packages for openldap

root@bhandari#] yum install openldap-servers

Now set the ldap admin password

root@bhandari#] slappasswd
New password:
Re-enter new password:
{SSHA}WifrivWxRE4Mx2uupJ+e9kz2Pc2uFHQJ

Now switch to the mention location

root@bhandari#] cd /etc/openldap/

Open the configuration file and edit it

root@bhandari#] vim slapd.conf

database        bdb
suffix          "dc=example,dc=com"
rootdn          "cn=Manager,dc=example,dc=com"
rootpw          {SSHA}WifrivWxRE4Mx2uupJ+e9kz2Pc2uFHQJ

Now maintain database cache by using following command

root@bhandari#] cp DB_CONFIG.example /var/lib/ldap/DB_CONFIG

root@bhandari#] chown -Rf ldap:ldap /var/lib/ldap/

Now test our configuration by running this command

root@bhandari#] slaptest

Now start ldap service

root@bhandari#] /etc/init.d/ldap start;chkconfig ldap on

Create the users for ldap by using script.

root@bhandari#] vim user.sh
#!/bin/bash
for i in {1..10};do
useradd -d /home/domain/ldapuser$i ldapuser$i
echo "redhat"|passwd --stdin ldapuser$i > /dev/null
done

root@bhandari#] cat /etc/passwd | grep ldapuser > /root/passwd

root@bhandari#] cat /etc/group | grep ldapuser > /root/group

root@bhandari#] cd /usr/share/openldap/migration

root@bhandari#] vim migrate_common.ph
# Default base
$DEFAULT_BASE = "dc=example,dc=com";

root@bhandari#] ./migrate_passwd.pl /root/passwd > /root/passwd.ldif

root@bhandari#] ./migrate_group.pl /root/group > /root/group.ldif

Now create the base ldif file

root@bhandari#] vim base.ldif

dn: dc=example,dc=com
dc: example
objectClass: top
objectClass: domain

dn: ou=People,dc=example,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit

dn: ou=Group,dc=example,dc=com
ou: Group
objectClass: top
objectClass: organizationalUnit

dn: ou=don,dc=example,dc=com
ou: don
objectClass: top
objectClass: organizationalUnit

First add base ldif in openldap database

root@bhandari#] ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f /root/base.ldif

Now add users and groups

root@bhandari#] ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f /root/passwd.ldif

root@bhandari#] ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f /root/group.ldif

we use nfs for sharing home directory to client machine.

root@bhandari#] yum install nfs

root@bhandari#] vim /etc/exports

/home/domain *(rw,sync)

root@bhandari#] /etc/init.d/nfs start;chkconfig nfs on

you can check ldap server users by run command

[root@bhandari#] ldapsearch -x -b "dc=example,dc=com"
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# example.com
dn: dc=example,dc=com
dc: example
objectClass: top
objectClass: domain

# People, example.com
dn: ou=People,dc=example,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit

# Group, example.com
dn: ou=Group,dc=example,dc=com
ou: Group
objectClass: top
objectClass: organizationalUnit

# don, example.com
dn: ou=don,dc=example,dc=com
ou: don
objectClass: top
objectClass: organizationalUnit

# ldapuser1, People, example.com
dn: uid=ldapuser1,ou=People,dc=example,dc=com
uid: ldapuser1
cn: ldapuser1
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJDc4Ri5INFN0JFQyOEhTdUg4UjJLVFJzYTN5S0RVaTA=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 500
gidNumber: 500
homeDirectory: /home/domain/ldapuser1

# ldapuser2, People, example.com
dn: uid=ldapuser2,ou=People,dc=example,dc=com
uid: ldapuser2
cn: ldapuser2
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJGpHZERnWTdjJGx1Uk1Fa0svWGlkN2JqeWREdE0uMzE=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 501
gidNumber: 501
homeDirectory: /home/domain/ldapuser2

# ldapuser3, People, example.com
dn: uid=ldapuser3,ou=People,dc=example,dc=com
uid: ldapuser3
cn: ldapuser3
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJDFiZGJxVk9YJEVZQkc3UldpTlAxS3B2cEhmNERxMy8=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 502
gidNumber: 502
homeDirectory: /home/domain/ldapuser3

# ldapuser4, People, example.com
dn: uid=ldapuser4,ou=People,dc=example,dc=com
uid: ldapuser4
cn: ldapuser4
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJEJLalIxS2dJJER0T3ZtNEU5czZyOTNIVnhRSUNpMzE=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 503
gidNumber: 503
homeDirectory: /home/domain/ldapuser4

# ldapuser5, People, example.com
dn: uid=ldapuser5,ou=People,dc=example,dc=com
uid: ldapuser5
cn: ldapuser5
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJEVCRlM5M3owJHVoS2xDQXNmUGh5cUI0Ni95ckVvNzA=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 504
gidNumber: 504
homeDirectory: /home/domain/ldapuser5

# ldapuser6, People, example.com
dn: uid=ldapuser6,ou=People,dc=example,dc=com
uid: ldapuser6
cn: ldapuser6
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJHZ1RWNQZTYyJFpQRTQvZjI3ZnRncjJ4dzZFZ2JTYi8=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 505
gidNumber: 505
homeDirectory: /home/domain/ldapuser6

# ldapuser7, People, example.com
dn: uid=ldapuser7,ou=People,dc=example,dc=com
uid: ldapuser7
cn: ldapuser7
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJHFSL0xIZUp0JDBmc3o4cnFhZFlQZHZ3WG5VTHAyeC8=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 506
gidNumber: 506
homeDirectory: /home/domain/ldapuser7

# ldapuser8, People, example.com
dn: uid=ldapuser8,ou=People,dc=example,dc=com
uid: ldapuser8
cn: ldapuser8
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJFJQREJKc1lZJGJtYWtwR2FBTklnMHBSZE9ZSlNHVC8=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 507
gidNumber: 507
homeDirectory: /home/domain/ldapuser8

# ldapuser9, People, example.com
dn: uid=ldapuser9,ou=People,dc=example,dc=com
uid: ldapuser9
cn: ldapuser9
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJGNCcW5ENnVpJGEyRmYwLmdnbmVacFIvQ1c3dEV6Vy8=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 508
gidNumber: 508
homeDirectory: /home/domain/ldapuser9

# ldapuser10, People, example.com
dn: uid=ldapuser10,ou=People,dc=example,dc=com
uid: ldapuser10
cn: ldapuser10
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJE9BbDJRSTZ6JEhIVWpiTXZQb09XQko1cmNVVkdWUzA=
shadowLastChange: 15856
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 509
gidNumber: 509
homeDirectory: /home/domain/ldapuser10

# ldapuser1, Group, example.com
dn: cn=ldapuser1,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser1
userPassword:: e2NyeXB0fXg=
gidNumber: 500

# ldapuser2, Group, example.com
dn: cn=ldapuser2,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser2
userPassword:: e2NyeXB0fXg=
gidNumber: 501

# ldapuser3, Group, example.com
dn: cn=ldapuser3,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser3
userPassword:: e2NyeXB0fXg=
gidNumber: 502

# ldapuser4, Group, example.com
dn: cn=ldapuser4,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser4
userPassword:: e2NyeXB0fXg=
gidNumber: 503

# ldapuser5, Group, example.com
dn: cn=ldapuser5,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser5
userPassword:: e2NyeXB0fXg=
gidNumber: 504

# ldapuser6, Group, example.com
dn: cn=ldapuser6,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser6
userPassword:: e2NyeXB0fXg=
gidNumber: 505

# ldapuser7, Group, example.com
dn: cn=ldapuser7,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser7
userPassword:: e2NyeXB0fXg=
gidNumber: 506

# ldapuser8, Group, example.com
dn: cn=ldapuser8,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser8
userPassword:: e2NyeXB0fXg=
gidNumber: 507

# ldapuser9, Group, example.com
dn: cn=ldapuser9,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser9
userPassword:: e2NyeXB0fXg=
gidNumber: 508

# ldapuser10, Group, example.com
dn: cn=ldapuser10,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser10
userPassword:: e2NyeXB0fXg=
gidNumber: 509

# search result
search: 2
result: 0 Success

# numResponses: 25
# numEntries: 24

Thanks & Regards
Manish Bhandari

Wednesday, 29 May 2013

How to configure Yum server in Rhel5, Rhel6,


                                             How to configure Yum server in Rhel6

What is Yum Server?

YUM stands for Yellow dog Updater Modified, is a easy way to install, update  rpm packages on linux operating system and also there dependencies automatically.

Why is need?

In RHEL4 installing packages is a tedious process, some times its headache to install all the dependencies. So Red-hat come with a solution to overcome this dependencies problem in most situations, the solution for this is nothing but YUM implementation. This will resolve this dependency issue and other known issues.

In Rhel we can create two type of yum servers.


  • Local yum server
  • Sharing yum server  

Now I am going to configure local yum server.

1. First you create the directory where you copy the DVD.

root@localhost#] mkdir /yum

mount the DVD

root@localhost#] mount /media/DVD /yum
root@localhost#] cd /media/DVD
root@localhost#] cp -rv * /yum

now create the repo file for yum server

root@localhost#] vim /etc/yum.repos.d/server.repo
[yum]
name=yum
baseurl=file:///yum
enabled=1
gpgcheck=0

After you can check it by using this command

root@localhost#] yum list all

Now I am going to create sharing yum server in linux

We can use yum server in network as yum client through FTP and HTTP.

First you install vsftpd package for FTP

root@localhost#] rpm -ivh vsftpd

after that you mount the DVD as you want like mnt

root@localhots#] mount /media/DVD /mnt

and copy it into ftp default location.

root@localhost#] cd /mnt

root@localhost#] cp -rv * /var/ftp/pub

Now create the repo file in server

root@localhost#] vim /etc/yum.repos.d/server.repo
[server]
name=yum
baseurl=file:///var/ftp/pub
gpgcheck=0

Now if client want to use yum sverer then he can used through FTP or HTTP

On client side

root@localhost#] vim /etc/yum.repos.d/client.repo
[server]
name=yum
baseurl=ftp://192.168.2.1/pub/
gpgcheck=0

Now you can check it through command

root@localhost#] yum list all

We can do same from httpd