Sunday 11 February 2018

Scenerio Based Linux Interview Questions with Answer

1. Which file have runlevel configuration?

/ect/inittab

2. What command would you use to shut down the system in 100 seconds?

#shutdown -h 100

3. What daemon controls the print spooling process?

The Line Printing Daemon (lpd) controls the print spooling process.

4. What configuration file defines the default runlevel for the init process?

/etc/inittab file defines the default runlevel for the init process.

5. Which command can you use to shut down and halt a Linux System?

The halt command will shut down a Linux system without rebooting

6. What init level should you set to bring the system to single-user mode?

init 1 will bring the system to single-user mode

7. A user wants to restart the NFS server because they want to enable changes made in the configuration file. What command accomplishes this task?

#service nfs reload

The reload command will tell the system to stop the service, reload the configuration file, and restart the service

8. What command can you use to reboot a Linux system?

The command to reboot a Linux system is reboot

9. What mode must you be in when using vi editor to input text into a file?

To insert text in the vi editor, you must be in insert mode
What runlevel does init 1 represent?

init 1 represents runlevel1. Runlevel 1 is used for single user mode.

10. One user from your company left the job without telling root account password of his system. To reset root password, in which mode you need to boot the system?

To reset the root password, we need to boot the system in single user mode.

11. What runlevel does init 2 represent?

init2 represents rulevel 2. runlevel 2 is used for multiuser without networking.

12. Some users are complaining that the DHCP server is not running. After examine the running processes on the system, you notice that the process is not present. What command should you use to start the DHCP service?

Because the service is currently not running, use the start command

#service dhcpd start

13. What runlevel does init 5 represent?

Runlevel 5 is used to boot up a full multiuser system and to automatically start X-windows.

14. What tar argument is used to extract files from an archive?

To extract files from an archive, use the -x argument in the tar command.

15. What init runlevel should be set to shut down and reboot the system?

init runlevel 6 is used to shut down and reboot the system

16. What command would you use to add the user name vickey?

#useradd vickey

This command will add the user viceky with default options. But this will not be able to login in system until you set a password for it. To set password use following command

#passwd vickey

17. Which runlevel currently not is used ?

Runlevel 4 is not used.

18. Your company hired a new developer for temporary periods to speed up the ongoing project. You are tasked to create a new user account which should be disabled automatically on 5 may 2014. How would you do that?

Use -e option with useradd command. -e option allows you to set the date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD. Following command will do the assigned task

#useradd -e 2014-05-05

19. Which command should you use to change the user information listed form finger command?

chfn command is used to change the information listed from finger command.

20. What runlevel does init 6 represent?

Runlevel 6 is used to reboot the system.

21. You are tasked to delete a user account with all his associated files including his home directory and mail folder. How will you do that ?

#userdel -r [username]

Above command will delete user account as well all his associated files including his home directory and mail folder.

22. A user comes to you and complain that his system was starting fine in GUI mode, but from last reboot system is starting in command line interface. What is the most likely cause of the problem?

In the /etc/inittab file, the default runlevel is probably set to 3, which tells it to start the system in command line.

23. What files are updated when adding a group?

/etc/group and /etc/gshadow files contains group information in Linux system. So these files would be updated every time whenever new group is added.

24. What command is used to delete a group?

The groupdel command will delete a group.

25. What runlevel does init 3 represent?

init3 represents rulevel 3. runlevel 3 is used for multiuser with networking.

26. What command will display the directory path that is currently in use?

pwd command will display the directory path that is currently in use.

27. A user type 'cd ~ ' on command prompt, what this command will do?

This command will move user to his or her home directory. ~ represents home directory in Linux.

28. A user comes to you and complain that his system start fine, but as soon as it is almost loaded it reboot again. What is the most likely cause of the problem?

In the /etc/inittab file, the default runlevel is probably set to 6, which tells it to reboot right after the system has started.

29. Which command will list all the files and sub-directories in a directory and include the access rights?

ls -l command will list all the files and sub-directories in a directory and include the access rights.

30. Which command will list all the files in a directory including hidden files?

ls -a command will list all the files in a directory including hidden files.

31. What is the correct syntax for the move command?

The correct syntax for the move command is

mv [options] [source] [destination]

32. Which character option with chmod command allows the execute-only permission if the file is a directory?

The x option is used to allow execute only if the file is a directory.

33. How will you display confirmation of the change of ownership of a file from rhuser1 to rhuser2?

Use --verbose option with chown command. For example

#chown --verbose rhuser2 /tmp/testfile

34. Which command is used to un-mount a DVD?

Use umount command to un-mount the DVD or CD or any other mounted media.

35. What runlevel does init 0 represent?

Runlevel 0 is used to halt /shutdown the system.

36. Which command will display the total size of all files, without listing the files, in a user's home directory?

The command du -c -s /home/user will display the total size of all files, without listing the files

37. Which command will display the available space of each partition in megabytes (MB)?

The command df -m will display the available space of each partition in MB.

38. Hard drive in your system is full and you want new hard drive. However sales department would not approve the expenditure without proof. Which tool would you use get a proof?

Use df command to justify the available free space in hard disk.

39. A user comes to you and complain that his system start fine, but as soon as it is almost loaded it shuts down again. What is the most likely cause of the problem?

In the /etc/inittab file, the default runlevel is probably set to 0, which tells it to shutdown right after the system has started.

LVM interview questions and answers.

1.Is it possible to increase the logical volume on fly?
Answer: Yes. LVM has the feature to increase the volume without unmount it.

2.How to reduce the logical volume? is it possible to reduce on fly?
Answer: No. we can't reduce the logical volume on fly. Here is the steps to reduce the logical volume.

Un-mount the filesystem
Run e2fsck on the volume device
Reduce the Filesystem using resize2fs
Reduce the logical Volume using lvreduce
Mount the filesystem back for production.

3.How do you scan the new LUN or disk?
Answer:Use "echo 1 > /sys/class/scsi_host/hostx/scan" to scan disk from newly connected SAN or DISKS and also replace the "x" with number of host id present under /sys/class/scsi_host/.

4.How to scan disks for existing volume group?
Answer:Use "vgscan" to scan existing volume group from newly connected SAN or DISKS.
But we should use "pvscan" prior to executing this command.

5.How to scan a logical volume from exising volume group?
Answer: lvscan

6.How to stop the logical volume? or deactivate the logical volume?
Answer: "lvchange -an /dev/vg_name/lv_name"


7.How to activate the logical volume which is in deactivated state?
Answer: "lvchange -ay /dev/vg_name/lv_name".

8.How to disable the volume group? or Deactivate the volume group?
Answer:"vgchange -an volume_group_name".

9.How to enable the volume group? or Activate the volume group?
Answer:"vgchange -ay volume_group_name" .

10.How do you find that what are the disks are used for logical volume mirroring?
Answer: use "lvs -a -o +devices"

11. What are steps to perform in order to increase the logical volume on fly?
Answer:
   Extend the logical volume
   Increase the Filesystem size
   Verify the status using df command or lvs command.



12.How to list the imported volume groups?
Answer: Use "vgs" command to display the imported volume group.

13.How to list the available logical volumes on the system?
Answer: Use "lvs" command to list the available logical volumes on the system.

14.How to list the available physical volumes in LVM?
Answer: Use "pvs" command to list the available physical volumes.

15.How to see the detailed volume group information?
Answer: Use "vgdisplay vg_name"
 
16.How to see the detailed logical volume information?
Answer: Use "lvdisplay /dev/vg_name/lv_name"

17.How to see the detailed physical volume information?
Answer: Use "pvdisplay /dev/disk_name"  Ex: pvdisplay /dev/sde

18.How to rename volume Group? can we rename the VG on fly?
Answer:Yes. Its possible to rename the volume group on fly. But the mounted volumes will not reflect the same unless you re-mount the volume with new VG name. Need to update the /etc/fstab with new VG name to mount the volumes across the system reboot.

19.How to take a LVM configuration backup?
Answer:Use "vgcfgbackup vg_name" to take the latest configuration backup of volume group. The default volume group backup location is "/etc/lvm/backup" .

20.How to re-create the device files for LVM volumes?
Answer:Run "vgmknodes" to recreate the LVM devices files.

21.What is lvmdump?
Answer: "lvmdump" is tool for LVM2 to collect the various information for diagnostic purposes.By default, it creates a tarball suitable for submission along with a problem report

22.How are snapshots in LVM2 different from LVM1 in Redhat Linux?
Answer:LVM1 snapshots are readonly by default where LVM2 snapshots were read/write.

23.What are the steps involved to create the logical volume from scratch?
Answer:
Create a physical volume using pvcreate command.
   #pvcreate /dev/sdc
Create a volume group using "vgcreate" command
   #vgcreate vg02 /dev/sdc
Create a logical volume using "lvcreate" command
   #lvcreate -L 100M -n vol1 vg02
Create a filesystem on logical volume using mkfs command.
    #mkfs -t ext4 /dev/vg02/vol1
Mount the filesystem using mount command for use.
    #mount -t ext4 /dev/vg02/vol1 /vol1

24.How to extent the volume group?
Answer:Using "vgextend" we can increase the volume group.

25.Assume Volume group "vg02" is already exists. How do you extend the volume group with 50GB? Provide all the steps with commands.
Answer:
   1.Get the 50GB lun from storage team.(/dev/sdd)
   2.Create physcical volume ( # pvcreate /dev/sdd )
   2.Extend the volume group (# vgextend vg02 /dev/sdd)

26.If the vg02 has two physical volumes called /dev/sdc/ & /dev/sdd. How do you remove /dev/sdd from vg02.
Answer: "vgreduce vg02 /dev/sdd/"

27.How to decommission/remove LVM completely from the host?
Answer:
     1.Un-mount all the logical filesystems
     2.Remove the logical volumes using "lvremove" command.
     3.Destroy the volume group using "vgremove" command.
     4.Use "pvremove" command remove the physical volumes from the system.

28. Why LVM is required?
Ans: LVM stands for Logical Volume Manager , to resize filesystem's size online we required LVM partition in Linux. Size of LVM partition can be extended and reduced using the lvextend & lvreduce commands respectively.

29. How to create partition from the raw disk?
Ans: Using fdisk utility we can create partitions from the raw disk.Below are the steps to create partition from the raw disk :
- fdisk /dev/hd* (IDE) or /dev/sd* (SCSI)
- Type n to create a new partition
- After creating partition , type w command to write the changes to the partition table.

Vmware Interview Questions and Answers

1. What is a Hypervisor?

It is a program that allows multiple operating systems to share a single hardware host. Each operating system appears to have the host's processor, memory, and other resources all to itself. However, the hypervisor is actually controlling the host processor and resources, allocating what is needed to each operating system in turn and making sure that the guest operating systems (called virtual machines) cannot disrupt each other.

2. What are the files that make a Virtual Machine?

     .vmx - Virtual Machine Configuration File
     .nvram - Virtual Machine BIOS
     .vmdk - Virtual Machine Disk file
     .vswp - Virtual Machine Swap File
     .vmsd - Virtual MAchine Snapshot Database
     .vmsn - Virtual Machine Snapshot file
     .vmss - Virtual Machine Suspended State file
     .vmware.log - Current Log File
     .vmware-#.log - Old Log file

3. What is the difference between the vSphere ESX and ESXi architectures?


VMware ESX and ESXi are both bare metal hypervisor architectures that install directly on the server hardware.

Although neither hypervisor architectures relies on an OS for resource management, the vSphere ESX architecture relied on a Linux operating system, called the Console OS (COS) or service console, to perform two management functions: executing scripts and installing third-party agents for hardware monitoring, backup or systems management.

In the vSphere ESXi architecture, the service console has been removed. The smaller code base of vSphere ESXi represents a smaller “attack surface” and less code to patch, improving reliability and security.

4. What is a .vmdk file?

This isn't the file containing the raw data. Instead it is the disk descriptor file which describes the size and geometry of the virtual disk file. This file is in text format and contains the name of the –flat.vmdk file for which it is associated with and also the hard drive adapter type, drive sectors, heads and cylinders, etc. One of these files will exist for each virtual hard drive that is assigned to your virtual machine. You can tell which –flat.vmdk file it is associated with by opening the file and looking at the Extent Description field.

5. What are the different types of virtualization?

Server Virtualization – consolidating multiple physical servers into virtual servers that run on a single physical server.

Application Virtualization – an application runs on another host from where it is installed in a variety of ways. It could be done by application streaming, desktop virtualization or VDI, or a VM package (like VMware ACE creates with a player). Microsoft Softgrid is an example of Application virtualization.

Presentation Virtualization – This is what Citrix Met frame (and the ICA protocol) as well as Microsoft Terminal Services (and RDP) are able to create. With presentation virtualization, an application actually runs on another host and all that you see on the client is the screen from where it is run.

Network Virtualization – with network virtualization, the network is “carved up” and can be used for multiple purposes such as running a protocol analyzer inside an Ethernet switch. Components of a virtual network could include NICs, switches, VLANs, network storage devices, virtual network containers, and network media.

Storage Virtualization – with storage virtualization, the disk/data storage for your data is consolidated to and managed by a virtual storage system. The servers connected to the storage system aren’t aware of where the data really is. Storage virtualization is sometimes described as “abstracting the logical storage from the physical storage.

6. What is VMware vMotion and what are its requirements?

VMware VMotion enables the live migration of running virtual machines from one physical server to another with zero downtime.

VMotion lets you:

    Automatically optimize and allocate entire pools of resources for maximum hardware utilization and
    availability.
    Perform hardware maintenance without any scheduled downtime.
    Proactively migrate virtual machines away from failing or under performing servers.

Below are the pre-requisites for configuring vMotion

    Each host must be correctly licensed for vMotion
    Each host must meet shared storage requirements
        vMotion migrates the vm from one host to another which is only possible with both the host are sharing a common storage or to any storage accessible by both the source and target hosts.
        A shared storage can be on a Fibre Channel storage area network (SAN), or can be implemented using iSCSI SAN and NAS.
        If you use vMotion to migrate virtual machines with raw device mapping (RDM) files, make sure to maintain consistent LUN IDs for RDMs across all participating hosts.

    Each host must meet the networking requirements
        Configure a VMkernel port on each host.
        Dedicate at least one GigE adapter for vMotion.
        Use at least one 10 GigE adapter if you migrate workloads that have many memory operations.
        Use jumbo frames for best vMotion performance.
        Ensure that jumbo frames are enabled on all network devices that are on the vMotion path including physical NICs, physical switches and virtual switches.

7. What is the difference between clone and template in VMware?

Clone

    A clone is a copy of virtual machine.
    You cannot convert back the cloned Virtual Machine.
    A Clone of a Virtual Machine can be created when the Virtual Machine is powered on
    Cloning can be done in two ways namely Full Clone and Linked Clone.
    A full clone is an independent copy of a virtual machine that shares nothing with the parent virtual machine after the cloning operation. Ongoing operation of a full clone is entirely separate from the parent virtual machine.
    A linked clone is a copy of a virtual machine that shares virtual disks with the parent virtual machine in an ongoing manner. This conserves disk space, and allows multiple virtual machines to use the same software installation.
    Cloning a virtual machine can save time if you are deploying many similar virtual machines. You can create, configure, and install software on a single virtual machine, and then clone it multiple times, rather than creating and configuring each virtual machine individually.
Template

    A template is a master copy or a baseline image of a virtual machine that can be used to create many clones.
    Templates cannot be powered on or edited, and are more difficult to alter than ordinary virtual machine.
    You can convert the template back to Virtual Machine to update the base template with the latest released patches and updates and to install or upgrade any software and again convert back to template to be used for future deployment of Virtual Machines with the latest patches.
    Convert virtual Machine to template cannot be performed, when Virtual machine is powered on.  Only Clone to Template can be performed when the Virtual Machine is powered on.
    A template offers a more secure way of preserving a virtual machine configuration that you want to deploy many times.
    When you clone a virtual machine or deploy a virtual machine from a template, the resulting cloned virtual machine is independent of the original virtual machine or template.

8. What is promiscuous mode in Vmware?

    Promiscuous mode is a security policy which can be defined at the virtual switch or portgroup level
    A virtual machine, Service Console or VMkernel network interface in a portgroup which allows use of promiscuous mode can see all network traffic traversing the virtual switch.
    If this mode is set to reject, the packets are sent to intended port so that the intended virtual machine will only be able to see the communication.
    Example: In case you are using a virtual xp inside any Windows VM. If promiscuous mode is set to reject then the virtual xp won't be able to connect the network unless promiscuous mode is enabled for the Windows VM.

9. What is the difference between Thick provision Lazy Zeroed, Thick provision Eager Zeroed and Thin provision?

Thick Provision Lazy Zeroed

    Creates a virtual disk in a default thick format.
    Space required for the virtual disk is allocated when the virtual disk is created.
    Data remaining on the physical device is not erased during creation, but is zeroed out on demand at a later time on first write from the virtual machine.
    Using the default flat virtual disk format does not zero out or eliminate the possibility of recovering deleted files or restoring old data that might be present on this allocated space.
    You cannot convert a flat disk to a thin disk.

Thick Provision Eager Zeroed

    A type of thick virtual disk that supports clustering features such as Fault Tolerance.
    Space required for the virtual disk is allocated at creation time.
    In contrast to the flat format, the data remaining on the physical device is zeroed out when the virtual disk is created.
    It might take much longer to create disks in this format than to create other types of disks.

Thin Provision

    It provides on on-demand allocation of blocks of data.
    All the space allocated at the time of creation of virtual disk is not utilized on the hard disk, rather only the size with utilized data is locked and the size increases as the amount of data is increased on the disk.
    With thin provisioning, storage capacity utilization efficiency can be automatically driven up towards 100% with very little administrative overhead.

10. What is a snapshot?

A snapshot is a “point in time image” of a virtual guest operating system (VM). That snapshot contains an image of the VMs disk, RAM, and devices at the time the snapshot was taken. With the snapshot, you can return the VM to that point in time, whenever you choose. You can take snapshots of your VMs, no matter what guest OS you have and the snapshot functionality can be used for features like performing image level backups of the VMs without ever shutting them down.

11. What is VDI?

    VDI stands for Virtual Desktop Infrastructure where end user physical machine like desktop or laptop are virtualized due to which VMware described VDI as "delivering desktops from the data center”.
    Once VDI is used the end user connect to their desktop using a device called thin client.
    The end user can also connect to their desktop using VMware Horizon View installed on any desktop or mobile devices
12. What is VMware HA?

    VMware HA i.e. High Availability which works on the host level and is configured on the Cluster.

    A Cluster configured with HA will migrate and restart all the vms running under any of the host in case of any host-level failure automatically to another host under the same cluster.

    VMware HA continuously monitors all ESX Server hosts in a cluster and detects failures.

    VMware HA agent placed on each host maintains a heartbeat with the other hosts in the cluster using the service console network. Each server sends heartbeats to the others servers in the cluster at five-second intervals. If any servers lose heartbeat over three consecutive heartbeat intervals, VMware HA initiates the failover action of restarting all affected virtual machines on other hosts.

    You can set virtual machine restart priority in case of any host failure depending upon the critical nature of the vm.

NOTE: Using HA in case of any host failure with RESTART the vms on different host so the vms state will be interrupted and it is not a live migration

13. What is the difference between VMware HA and vMotion?

VMware HA is used in the event when any of the hosts inside a cluster fails then all the virtual machines running under it are restarted on different host in the same cluster.

Now HA is completely dependent on vMotion to migrate the vms to different host so vMotion is just used for the migration purpose between multiple hosts. vMotion also has the capability to migrate any vm without interrupting its state to any of the host inside cluster.

14. What is storage vMotion?

    Storage vMotion is similar to vMotion in the sense that "something" related to the VM is moved and there is no downtime to the VM guest and end users. However, with SVMotion the VM Guest stays on the server that it resides on but the virtual disk for that VM is what moves.
    With Storage vMotion, you can migrate a virtual machine and its disk files from one datastore to another while the virtual machine is running.
    You can choose to place the virtual machine and all its disks in a single location, or select separate locations for the virtual machine configuration file and each virtual disk.
    During a migration with Storage vMotion, you can transform virtual disks from Thick-Provisioned Lazy Zeroed or Thick-Provisioned Eager Zeroed to Thin-Provisioned or the reverse.
    Perform live migration of virtual machine disk files across any Fibre Channel, iSCSI, FCoE and NFS storage

15. What is VMware DRS and how does it works?

    Here DRS stands for Distributed Resource Scheduler which dynamically balances resource across various host under Cluster or resource pool.
    VMware DRS allows users to define the rules and policies that decide how virtual machines share resources and how these resources are prioritized among multiple virtual machines.
    Resources are allocated to the virtual machine by either migrating it to another server with more available resources or by making more “space” for it on the same server by migrating other virtual machines to different servers.
    The live migration of virtual machines to different physical servers is executed completely transparent to end-users through VMware VMotion
    VMware DRS can be configured to operate in either automatic or manual mode. In automatic mode, VMware DRS determines the best possible distribution of virtual machines among different physical servers and automatically migrates virtual machines to the most appropriate physical servers. In manual mode, VMware DRS provides a recommendation for optimal placement of virtual machines, and leaves it to the system administrator to decide whether to make the change.

16. What is VMware Fault Tolerance?

    VMware Fault Tolerance provides continuous availability to applications running in a virtual machine, preventing downtime and data loss in the event of server failures.
    VMware Fault Tolerance, when enabled for a virtual machine, creates a live shadow instance of the primary, running on another physical server.
    The two instances are kept in virtual lockstep with each other using VMware vLockstep technology
    The two virtual machines play the exact same set of events, because they get the exact same set of inputs at any given time.
    The two virtual machines constantly heartbeat against each other and if either virtual machine instance loses the heartbeat, the other takes over immediately. The heartbeats are very frequent, with millisecond intervals, making the failover instantaneous with no loss of data or state.
    VMware Fault Tolerance requires a dedicated network connection, separate from the VMware VMotion network, between the two physical servers.

17. In a cluster with more than 3 hosts, can you tell Fault Tolerance where to put the Fault Tolerance virtual machine or does it chose on its own?

You can place the original (or Primary virtual machine). You have full control with DRS or vMotion to assign it to any node. The placement of the Secondary, when created, is automatic based on the available hosts. But when the Secondary is created and placed, you can vMotion it to the preferred host.

18. How many virtual CPUs can I use on a Fault Tolerant virtual machine?

vCenter Server 4.x and vCenter Server 5.x support 1 virtual CPU per protected virtual machine.

19. What happens if vCenter Server is offline when a failover event occurs?

When Fault Tolerance is configured for a virtual machine, vCenter Server need not be online for FT to work. Even if vCenter Server is offline, failover still occurs from the Primary to the Secondary virtual machine. Additionally, the spawning of a new Secondary virtual machine also occurs without vCenter Server.

20. What is the difference between Type 1 and Type 2 Hypervisor?

Type 1 Hypervisor

    This is also known as Bare Metal or Embedded or Native Hypervisor.
    It works directly on the hardware of the host and can monitor operating systems that run above the hypervisor.
    It is completely independent from the Operating System.
    The hypervisor is small as its main task is sharing and managing hardware resources between different operating systems.
    A major advantage is that any problems in one virtual machine or guest operating system do not affect the other guest operating systems running on the hypervisor.
    Examples: VMware ESXi Server, Microsoft Hyper-V, Citrix/Xen Server
Type 2 Hypervisor

    This is also known as Hosted Hypervisor.
    In this case, the hypervisor is installed on an operating system and then supports other operating systems above it.
    It is completely dependent on host Operating System for its operations
    While having a base operating system allows better specification of policies, any problems in the base operating system a ffects the entire system as well even if the hypervisor running above the base OS is secure.
    Examples: VMware Workstation, Microsoft Virtual PC, Oracle Virtual Box

21. How does vSphere HA works?

When we configure multiple hosts for HA cluster, a single host is automatically elected as the master host. The master host communicates with vCenter Server and monitors the state of all protected virtual machines and of the slave hosts. When you add a host to a vSphere HA cluster, an agent is uploaded to the host and configured to communicate with other agents in the cluster.

22. What are the monitoring methods used for vSphere HA?

The Master and Slave hosts uses two types of monitoring the status of the hosts

    Datastore Heartbeat
    Network Heartbeat

23. What are the roles of master host in vSphere HA?

    Monitoring the state of slave hosts. If a slave host fails or becomes unreachable, the master host identifies which virtual machines need to be restarted.
    Monitoring the power state of all protected virtual machines. If one virtual machine fails, the master host ensures that it is restarted. Using a local placement engine, the master host also determines where the restart should be done.
    Managing the lists of cluster hosts and protected virtual machines.
    Acting as vCenter Server management interface to the cluster and reporting the cluster health state.

24. How is a Master host elected in vSphere HA environment?

When vSphere HA is enabled for a cluster, all active hosts (those not in standby or maintenance mode, or not disconnected) participate in an election to choose the cluster's master host. The host that mounts the greatest number of datastores has an advantage in the election. Only one master host typically exists per cluster and all other hosts are slave hosts.

If the master host fails, is shut down or put in standby mode, or is removed from the cluster a new election is held.

25. If the vCenterserver goes down with a situation that it was pre configured with vSphere HA and DRS, so after power down will HA and DRS perform their task?

vSphere HA is not dependent on vCenterserver for its operations as when HA is configured it installs an agent into each host which does its part and is not dependent on vCenterserver. Also HA doesnot uses vMotion, it justs restarts the vms into another host in any case of host failure.

Further vSphere DRS is very much dependent on vCenterserver as it uses vMotion for its action for live migration of vms between multiple hosts so in case vCenterserver goes down the vMotion won't work leading to failure of DRS.

26. What is the use of vmware tools?

VMware Tools is a suite of utilities that enhances the performance of the virtual machine's guest operating system and improves management of the virtual machine. Without VMware Tools installed in your guest operating system, guest performance lacks important functionality. Installing VMware Tools eliminates or improves these issues:

    Low video resolution
    Inadequate color depth
    Incorrect display of network speed
    Restricted movement of the mouse
    Inability to copy and paste and drag-and-drop files
    Missing sound
    Provides the ability to take quiesced snapshots of the guest OS
    Synchronizes the time in the guest operating system with the time on the host
    Provides support for guest-bound calls created with the VMware VIX API

Tuesday 6 February 2018

vSphere 5 vs vSphere 6 Difference between both versions

vSphere 5 vs vSphere 6 Difference between both versions

19 grep command examples

grep command examples
Learn grep command with examples

grep : one of the widely used Linux / Unix command which helps sysadmins narrowing down their searches! grep stands for Global Regular Expression Print which is used for searching regular expressions within source stream of data.
grep command syntax is simple.
grep <switch> <string to search> file
where, switch is from variety of switches available to use with command. string to search is regular expression which you want to search within source data. file is source f data in which you expect grep command to search.
It is also used widely with pipe for searching strings in data outputted by previous command. In such scenario, syntex followed is –
command1 | grep <switch> <string to search>
where, output of command1 is being searched using grep command.
We are sharing here 19 grep command practical examples which will help beginners to well versed with this command and use it in their daily operations. Without further delay, lets learn grep command with below 20 examples. In all below examples we will be searching string ‘kerneltalks’

Find out string in file

Recursive search in directory

You can use recursive grep in directory to search for string/pattern in all files within a directory.

Count pattern match in grep

You can use -c i.e. count switch with grep command to count how many times pattern is matched in given data.

Search exact word in file

Normally, grep returns lines from data which has pattern matching in it. If you want to search exact word in data then use -w switch.
You can combine it with count switch above and can get number of times exact word appeared in file.

Ignore case while searching with grep

To ignore case while finding match use -i switch i.e. case insensitive match. So when you search for kerneltalks with -i switch it will show occurrence of kerneltalks, KERNELTALKS, KernelTalks etc.

Use of wild card with grep

Wild cards or repetition operators can be used with grep command.
here, * match anything which precedes with string kernel. You can use repetition operators like ?, *, + with grep.

Reverse grep operation

If you want to display data just by omitting the lines containing your targeted string then you can use grep operation in reverse way i.e. by using -v switch. Some people also call it as invert match or grep operation.
Above command displays all lines within file1 except the ones which contains string kerneltalks.

Display N lines before matching string using grep

Use of -A switch followed by N number argument will let you display N lines before matching string in file.
Above command will display 5 lines above the line which contains string kerneltalks

Display N lines after matching string using grep

Opposite to above, if you want to display N liens after match is found, use -B switch with same above syntax.
Here it will display 4 lines below the line which has string kerneltalks in it.

Display N lines around matching string using grep

Using both -A and -B switches, you can display N lines before and after of matching string line. But, grep comes with inbuild switch -C which will do this for you.
Above command will display 3 lines above and 3 lines after the line which has matching string.

Match multiple pattern with grep

Searching more than one pattern/string is possible with grep. Stack up your strings using -e switch.
It will search for string1 and string2 in file1 and display all lines with either of string in them.

List only file names with matching string in them

When you are searching through bunch of files and only interested in file names within which string is matched then use -l switch.
Here we re searching string kerneltalks in all files ending with .log. Since -l switch is used, grep will display only file names where string match is found.

Display line number of match with grep

If you want to get the line number where your string found the match, you can use -n switch.

Display matched string only rather than whole line of match

By default, grep displays whole line which contains the match of your searched string. To display only matched string rather than whole line, you need to use -o switch. Obviously, it not useful when you are searching whole string or word but it is very useful when you re searching with wild cards.

Coloring up your grep search output

To highlight matched strings in output use -color switch

Grep out blank lines

You can search and count for blank lines with grep.
Its helpful for removing blank lines from file and get only data lines. Use reverse grep we saw earlier (-vswitch)
It will show you only data lines, omitting all blank lines. You can redirect it to new file and get clean data file! You can use same technique to remove hashed entries from file by using ^# as a search string. This will helps removing comments from scripts as well.

Invoke Egrep using grep

Egrep is extended grep with additional character support. egrep is derivative from grep utility. You can use it with egrep command or invoke using grep as below :

Fixed grep Fgrep using grep

Fixed grep is used for fast searching direct strings without any meta characters or regular expressions. As name suggests, fgrep is fixed grep! Only direct strings to search and it will be bit fast than normal grep. fgrep is also another derivative from normal grep and used as fgrep separate command. But it can also be invoked using grep with below switch –

Search pattern in zip file

One more derivative of grep is zgrep. IT is used to find and match string in zip files. It uses almost same switches as grep only difference is you have to source it zip file to search

Let us know if you have any other grep command examples in comments below which re really helpful for sysadmin in day to day operations.