DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.


Showing posts with label rhel. Show all posts
Showing posts with label rhel. Show all posts

Difference between RHEL6 and RHEL7

Below are the major differences between RHEL 6 and 7.

On the release date for 6 & 7
RHEL 6: 10 NOV 2010
RHEL 7: 10 JUNE 2014
The latest is RHEL 7

Difference on the basis of operating system names
if we want to see use this command
# cat /etc/redhat-release
RHEL 6: SANTIGO
RHEL 7: MAIPO

Kernel version
If we want to see in terminal use this command: lsb_release -a or uname -a
RHEL 6: 2.6.32
RHEL 7: 3.0.10

OS boot time
RHEL 6: 40 sec
RHEL 7: 20 sec

Maximum size of single partition
RHEL 6: 50TB(EXT4)
RHEL 7: 500TB(XFS)

Boot loader
RHEL 6: /boot/grub/grub.conf
RHEL 7: /boot/grupb2/grub.cfg

Processor architecture
RHEL 6: It support 32bit & 64bit both
RHEL 7: It only support 64bit

How to format or assign a file system in
RHEL 6: # mkfs.ext4 /dev/hda6
RHEL 7: # mkfs.xfs /dev/hda6

How to repair a file system in
RHEL 6: # fsck -y /dev/hda6
RHEL 7: # xfs_repair /dev/hda6

Command to manage network
RHEL 6: # setup
RHEL 7: # nmtui

Host name configuration file
RHEL 6: /etc/sysconfig/network
RHEL 7: /etc/hostname

Default ISO image mount path
RHEL 6: /media
RHEL 7: /run/media/root

File system check
RHEL 6: e2fsck
RHEL 7: xfs_repair

Resize a filesystem
RHEL 6: # resize2fs -p /dev/vg00/lv1
RHEL 7: # xfs_growfs /dev/vg00/lv1

Tune a filesystem
RHEL 6: tune2fs
RHEL 7: xfs_admin

IP tables and firewalls
RHEL 6: iptables
RHEL 7: firewalled

Communication between TCP and UDP in backend
RHEL 6: netcat
RHEL 7: ncat

Interface name
RHEL 6: eth0
RHEL 7: ens198(N)

Combining NIC
RHEL 6: Network Bonding
RHEL 7: Team Driver

NFS server version

RHEL 6: NFSv2
RHEL 7: NFSV4

Database used
RHEL 6: Mysql
RHEL 7: mariaDB

Managing services
RHEL 6:
# service sshd restart
# chkconfig sshd on
RHEL 7:
# systemctl restart sshd
# systemctl enable shhd

How to add a new network gateway or static route on Red Hat Enterprise Linux host?

To add a static route or gateway on Red Hat Enterprise Linux host, such as when adding for a second (or tertiary) interface, use the /etc/sysconfig/network-scripts/route-<interface> files. These configuration filesare read during network service initialization. For example to add static route for eth0, create a file /etc/sysconfig/network-scripts/route-eth0 and add the routes as explained below.

There are two possible formats for this file. The first is with ip command arguments and the second is with network/netmask directives.

Format 1:
  • For ip commands, the ifup-route script supplies ip route add and the contents of the file are all parameters necessary to set up the route. For example, to set up a default route, the file would contain the following:
    default via X.X.X.X
    Y.Y.Y.Y via Z.Z.Z.Z
    
    e.g
    default via 192.168.1.1
    10.10.10.0/24 via 192.168.1.2
    
  • In the above, X.X.X.X is the gateway IP address. The second line adds another static route where Y.Y.Y.Y is the network, Z.Z.Z.Z is the gateway IP address. Multiple lines will be parsed as individual routes.

Format 2:
  • The alternative format is as follows:
    ADDRESS<N>=X.X.X.X
    NETMASK<N>=Y.Y.Y.Y
    GATEWAY<N>=Z.Z.Z.Z
    
    e.g.
    ADDRESS0=10.10.10.0
    NETMASK0=255.255.255.0
    GATEWAY0=192.168.1.2
    ADDRESS1=20.20.20.0
    NETMASK1=255.255.255.0
    GATEWAY1=192.168.1.2
    
  • This format deals with three fields: GATEWAY, NETMASK, and ADDRESS. Each field should have a number appended to it indicating which route it relates to.
  • In the above example, Z.Z.Z.Z is the gateway IP address. Subsequent entries must be numbered sequentially (for example ADDRESS1=, NETMASK1=, GATEWAY1=). Note, that multiple entries must be sequentially numbered and must not skip a value (0 must be followed by 1, not a number greater than 1).

Monitoring Filesystem Events with incron on RHEL 6

Have you ever wanted to know when a file is changed or accessed by the system or user? There is a program that does just that task called Inotify cron (incron).

Incron is for monitoring filesystem activity. It consists of a daemon and a table manipulator. You can use it a similar way as the regular cron. The difference is that the inotify cron handles filesystem events rather than time periods

incron provides a simple way how to solve many and many various situations. Every time when something depends on file system events, it’s a job for incron.

Here you can see a few examples where incron is a good solution:
  1.     Notifying programs (e.g. server daemons) about changes in configuration
  2.     Guarding changes in critical files (with their eventual recovery)
  3.     File usage monitoring, statistics.

First we will need to install incron:
$ sudo yum install incron

Make sure we set it to start on reboot:
$ sudo chkconfig incrond on

And now to start incron:
$ sudo service incrond start

incrond uses inotify. So to use it effectively we need to have it act on inotify events which are:
 IN_ACCESS         File was accessed (read) (*).
 IN_ATTRIB         Metadata  changed,  e.g.,  permissions,  timestamps, 
                   extended attributes, link count (since Linux 2.6.25), 
                   UID, GID, etc. (*).
 IN_CLOSE_WRITE    File opened for writing was closed (*).
 IN_CLOSE_NOWRITE  File not opened for writing was closed (*).
 IN_CREATE         File/directory created in watched directory (*).
 IN_DELETE         File/directory deleted from watched directory (*).
 IN_DELETE_SELF    Watched file/directory was itself deleted.
 IN_MODIFY         File was modified (*).
 IN_MOVE_SELF      Watched file/directory was itself moved.
 IN_MOVED_FROM     File moved out of watched directory (*).
 IN_MOVED_TO       File moved into watched directory (*).
 IN_OPEN           File was opened (*).
 
The incron table manipulator may be run under any regular user since it SUIDs. For manipulation with the tables use basically the same syntax as for the crontab program. You can import a table, remove and edit the current table.

The user table rows have the following syntax (use one or more spaces between elements):
<path> <mask> <command>
Where?
<path> is a filesystem path (each whitespace must be prepended by a backslash)
<mask> is a symbolic or numeric mask for events (see man inotify for more details)
<command> is an application or script to run on the events

The command may contain these wildcards:
 $$ - a dollar sign
 $@ - the watched filesystem path (see above)
 $# - the event-related file name
 $% - the event flags (textually)
 $& - the event flags (numerically)
Now with all that information, what can I do? Say you want to be notified each time /etc/hosts is modified and email us. Open incrontab make sure you are root for this example:
# incrontab -e

/etc/hosts IN_MODIFY mailx -s "Hosts file Has Been modified" mymail@mymail.com
Save the changes and open /etc/hosts and make a change and you should receive an email in your inbox.
At this point we have covered just the basics of what is possible with incron. Experiment with incron and see what other items you can monitor and what other commands you can execute on filesystem actions.

Linux boot process

In this topic we will discuss indepth of Linux Boot Sequence.How a linux system boots?
This will help unix administrators in troubleshooting some bootup problem.
Before discussing about it I will notedown the major component we need to know which are responsible for the booting process.

        1.BIOS(Basic Input/Output System)
        2.MBR(Master Boot Record)
        3.LILO or GRUB
             LILO:-LInux LOader
             GRUB:-GRand Unified Bootloader
        4.Kernel
        5.init
        6.Run Levels


1.BIOS:
      i.When we power on BIOS performs a Power-On Self-Test (POST) for all of the different hardware components in the system to make sure everything is working properly
     ii.Also it checks for whether the computer is being started from an off position (cold boot) or from a restart (warm boot) is
stored at this location.
     iii.Retrieves information from CMOS (Complementary Metal-Oxide Semiconductor) a battery operated memory chip on the motherboard that stores time, date, and critical system information.
     iv.Once BIOS sees everything is fine it will begin searching for an operating system Boot Sector on a valid master boot sector
on all available drives like hard disks,CD-ROM drive etc.
     v.Once BIOS finds a valid MBR it will give the instructions to boot and executes the first 512-byte boot sector that is the first
sector (“Sector 0″) of a partitioned data storage device such as hard disk or CD-ROM etc .
2.MBR
     i. Normally we use multi-level boot loader.Here MBR means I am referencing to DOS MBR.
     ii.Afer BIOS executes a valid DOS MBR,the DOS MBR will search for a valid primary partition marked as bootable on the hard disk.
     iii.If MBR finds a valid bootable primary partition then it executes the first 512-bytes of that partition which is second level MBR.
     iv. In linux we have two types of the above mentioned second level MBR known as LILO and GRUB
3.LILO
     i.LILO is a linux boot loader which is too big to fit into single sector of 512-bytes.
     ii.So it is divided into two parts :an installer and a runtime module.
     iii.The installer module places the runtime module on MBR.The runtime module has the info about all operating systems installed.
     iv.When the runtime module is executed it selects the operating system to load and transfers the control to kernel.
     v.LILO does not understand filesystems and boot images to be loaded and treats them as raw disk offsets
GRUB
     i.GRUB MBR consists of 446 bytes of primary bootloader code and 64 bytes of the partition table.
     ii.GRUB locates all the operating systems installed and gives a GUI to select the operating system need to be loaded.
     iii.Once user selects the operating system GRUB will pass control to the karnel of that operating system.
see below what is the difference between LILO and GRUB
4.Kernel
     i.Once GRUB or LILO transfers the control to Kernel,the Kernels does the following tasks
  • Intitialises devices and loads initrd module
  • mounts root filesystem
5.Init
     i.The kernel, once it is loaded, finds init in sbin(/sbin/init) and executes it.
     ii.Hence the first process which is started in linux is init process.
     iii.This init process reads /etc/inittab file and sets the path, starts swapping, checks the file systems, and so on.
     iv.It runs all the boot scripts(/etc/rc.d/*,/etc/rc.boot/*)
     v.starts the system on specified run level in the file /etc/inittab

6.Runlevel
     i.There are 7 run levels in which the linux OS runs and different run levels serves for different purpose.The descriptions are
given below.
  • 0  – halt
  • 1  – Single user mode
  • 2  – Multiuser, without NFS (The same as 3, if you don’t have networking)
  • 3  – Full multiuser mode
  • 4  – unused
  • 5  – X11
  • 6  – Reboot
     ii.We can set in which runlevel we want to run our operating system by defining it on /etc/inittab file.
Now as per our setting in /etc/inittab the Operating System the operating system boots up and finishes the bootup process.
Below are given some few  important differences about LILO and GRUB
LILO
GRUB
LILO has no interactive command interface GRUB has interactive command interface
LILO does not support booting from a network GRUB does support booting from a network
If you change your LILO config file, you have to rewrite the LILO stage one boot loader to the MBR GRUB automatically detects any change in config file and auto loads the OS
LILO supports only linux operating system GRUB supports large number of OS