Posts

Showing posts from 2017

Python reference Interview questions

1)HCL Python scripting developer Interview questions:- 1) How do you check list of files in the given path in python ?? 2) How do you check whether file is exist or not in python 3) How do you perform copy file cmd in python ?? 4) What is d use of setup.py in python 5) What is d use of __init__=__main__: condition in python?? 6) What is d type of *args and **kargs ?? 7) sys.path use in python ??   2) CES Limited Python developer Interview Face2Face Interview questions:- 1.Basic questions on oops:   *.Implement Base class using Instance, static and Abstract method     instance method - takes two arguments to add operation     static method - takes two args to multiply operation     abstract method - takes two args to div operation   *. Implement child class using 3 instance methods     instance - takes three args for add operation     instance - takes two args for...

Differences between bin, sbin, /usr/bin and /usr/sbin

/bin This directory contains executable programs which are needed in single user mode and to bring the system up or repair it. /sbin Like /bin, this directory holds commands needed to boot the system, but which are usually not executed by normal users. /usr/bin This is the primary directory for executable programs. Most programs executed by normal users which are not needed for booting or for repairing the system and which are not installed locally should be placed in this directory. /usr/local This is where programs which are local to the site typically go. /usr/local/bin Binaries for programs local to the site. /usr/local/sbin Locally installed programs for system administration.

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-...