Posts

Successful or Fail login process in Linux

When the Linux system boots up you get a console similar to below, machine_name login: This prompt is generated by a program called  getty  which is regenerated every time when an incorrect  password  is provided, by the init process which is again created by  fork  function. NOTE:   Fork  is a function which creates a new process by duplicating the calling process. The new process, referred to as the child, is an exact duplicate of the calling process, referred to as the parent. To be brief the Linux login works as per the below steps Getty  process presents the login prompt to the user console Once the username is provided, the password is validated and if successful the user is allowed to login into the shell If there is a failure getty process is re-initiated by the fork function and the password prompt re-appears. The maximum number of failure attempts would be allowed as defined under the pam configur...

Procedure to Reduce the Logical Volume

Scenario :   Suppose we want to reduce  /home  by 2GB which is LVM and formated as  ext4. [root@cloud ~]# df -h /home/ Filesystem            Size  Used Avail Use% Mounted on /dev/mapper/vg_cloud-LogVol00 12G  9.2G  1.9G  84% /home Step:1 Umount the filesystem [root@cloud ~]# umount /home/ Step:2 check the filesystem for Errors using e2fsck command. [ root@cloud ~]# e2fsck -f /dev/mapper/vg_cloud-LogVol00 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/mapper/vg_cloud-LogVol00: 12/770640 files (0.0% non-contiguous), 2446686/3084288 blocks Note:  In the above command  e2fsck  , we use the option  ‘-f’  to forcefully check the filesystem , even if the filesystem is clean. Step...

Comparing temporary and Persistant routes in Linux

Hi This script will help us to compare the routes which is persistent and which is not. ################################################################################# #!/bin/bash  ifconfig | grep addr | awk '{print $1}' > /tmp/interfaces && sed -i.bak_$time "s/inet6*//g" /tmp/interfaces  for i in $(cat /tmp/interfaces);  do  echo "******* Verifying routes on $i interface ********"  cp /etc/sysconfig/network-scripts/route-$i /tmp/route-$i  route -n | grep -i $i | grep -i ug  |awk '{print $1}' > /tmp/currentroutes  echo "***** Comparing Current and Persistant Routes on $i *****" for j in $(cat /tmp/currentroutes);          do          cat /tmp/route-$i | grep $j     if [ $? == 0 ]     then echo "***** route $j is persistent on $(hostname) *****"     else echo "#### route $j is not persistent on $(hostname) on $i ####"   ...

Crontab entries

Linux Crontab Format MIN HOUR DOM MON DOW CMD Table: Crontab Fields and Allowed Ranges (Linux Crontab Syntax) Field Description Allowed Value MIN Minute field 0 to 59 HOUR Hour field 0 to 23 DOM Day of Month 1-31 MON Month field 1-12 DOW Day Of Week 0-6 CMD Command Any command to be executed. 1. Scheduling a Job For a Specific Time The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on  10th June 08:30 AM . Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20. 30 08 10 06 * /home/ramesh/full-backup 30  – 30th Minute 08  – 08 AM 10  – 10th Day 06  – 6th Month (June) *  – Every day of the week 2. Schedule a Job For More Than One Instance (e.g. Twice a Day) The following script take a incremental backup twice a day every day. This example executes the specified incremental backup shell script (incremental-...

How to Increase the size of a Linux LVM by expanding the virtual machine disk

Image
Identifying the partition type As this method focuses on working with LVM, we will first confirm that our partition type is actually Linux LVM by running the below command. fdisk -l As you can see in the above image /dev/sda5 is listed as “Linux LVM” and it has the ID of 8e. The 8e hex code shows that it is a Linux LVM, while 83 shows a Linux native partition. Now that we have confirmed we are working with an LVM we can continue. For increasing the size of a Linux native partition (hex code 83)  see this article. Below is the disk information showing that our initial setup only has the one 20gb disk currently, which is under the logical volume named /dev/mapper/Mega-root – this is what we will be expanding with the new disk. Note that /dev/mapper/Mega-root is the volume made up from /dev/sda5 currently – this is what we will be expanding. Increasing the virtual hard disk First off we increase the allocated disk space on the virtual machine itself. This is done by r...