This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Thursday, October 1, 2015

How to Configure Linux Cluster with 2 Nodes on RedHat and CentOS

Thursday, October 01, 2015 0
In an active-standby Linux cluster configuration, all the critical services including IP, filesystem will failover from one node to another node in the cluster.

It explains how to create and configure two node redhat cluster using command line utilities.
The following are the high-level steps involved in configuring Linux cluster on Redhat or CentOS:
• Install and start RICCI cluster service
• Create cluster on active node
• Add a node to cluster
• Add fencing to cluster
• Configure fail over domain
• Add resources to cluster
• Sync cluster configuration across nodes
• Start the cluster
• Verify fail over by shutting down an active node

1. Required Cluster Packages

First make sure the following cluster packages are installed. If you don’t have these packages install them using yum command.
[root@rh1 ~]# rpm -qa | egrep -i "ricci|luci|cluster|ccs|cman"
modcluster-0.16.2-28.el6.x86_64
luci-0.26.0-48.el6.x86_64
ccs-0.16.2-69.el6.x86_64
ricci-0.16.2-69.el6.x86_64
cman-3.0.12.1-59.el6.x86_64
clusterlib-3.0.12.1-59.el6.x86_64

2. Start RICCI service and Assign Password

Next, start ricci service on both the nodes.

[root@rh1 ~]# service ricci start
Starting oddjobd: [ OK ]
generating SSL certificates... done
Generating NSS database... done
Starting ricci: [ OK ]

You also need to assign a password for the RICCI on both the nodes.

[root@rh1 ~]# passwd ricci
Changing password for user ricci.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Also, If you are running iptables firewall, keep in mind that you need to have appropriate firewall rules on both the nodes to be able to talk to each other.

3. Create Cluster on Active Node

From the active node, please run the below command to create a new cluster.
The following command will create the cluster configuration file /etc/cluster/cluster.conf. If the file already exists, it will replace the existing
cluster.conf with the newly created cluster.conf.

[root@rh1 ~]# ccs -h rh1.mydomain.net --createcluster mycluster
rh1.mydomain.net password:

[root@rh1 ~]# ls -l /etc/cluster/cluster.conf
-rw-r-----. 1 root root 188 Sep 26 17:40 /etc/cluster/cluster.conf
Also keep in mind that we are running these commands only from one node on the cluster and we are not yet ready to propagate the changes
to the other node on the cluster.

4. Initial Plain cluster.conf File

After creating the cluster, the cluster.conf file will look like the following:
[root@rh1 ~]# cat /etc/cluster/cluster.conf
<?xml version="1.0"?>
<cluster config_version="1" name="mycluster">
<fence_daemon/>
<clusternodes/>
<cman/>
<fencedevices/>
<rm>
<failoverdomains/>
<resources/>
</rm>
</cluster>


5. Add a Node to the Cluster

Once the cluster is created, we need to add the participating nodes to the cluster using the ccs command as shown below.
First, add the first node rh1 to the cluster as shown below.

[root@rh1 ~]# ccs -h rh1.mydomain.net --addnode rh1.mydomain.net
Node rh1.mydomain.net added.

Next, add the second node rh2 to the cluster as shown below.
[root@rh1 ~]# ccs -h rh1.mydomain.net --addnode rh2.mydomain.net
Node rh2.mydomain.net added.
Once the nodes are created, you can use the following command to view all the available nodes in the cluster. This will also display the node
id for the corresponding node.

[root@rh1 ~]# ccs -h rh1 --lsnodes
rh1.mydomain.net: nodeid=1
rh2.mydomain.net: nodeid=2

6. cluster.conf File After Adding Nodes

This above will also add the nodes to the cluster.conf file as shown below.

[root@rh1 ~]# cat /etc/cluster/cluster.conf
<?xml version="1.0"?>
<cluster config_version="3" name="mycluster">
<fence_daemon/>
<clusternodes>
<clusternode name="rh1.mydomain.net" nodeid="1"/>
<clusternode name="rh2.mydomain.net" nodeid="2"/>
</clusternodes>
<cman/>
<fencedevices/>
<rm>
<failoverdomains/>
<resources/>
</rm>
</cluster>

7. Add Fencing to Cluster

Fencing is the disconnection of a node from shared storage. Fencing cuts off I/O from shared storage, thus ensuring data integrity.
A fence device is a hardware device that can be used to cut a node off from shared storage.
This can be accomplished in a variety of ways: powering off the node via a remote power switch, disabling a Fiber Channel switch port, or revoking a host’s SCSI 3 reservations.
A fence agent is a software program that connects to a fence device in order to ask the fence device to cut off access to a node’s shared storage (via powering off the node or removing access to the shared storage by other means).
Execute the following command to enable fencing.

[root@rh1 ~]# ccs -h rh1 --setfencedaemon post_fail_delay=0
[root@rh1 ~]# ccs -h rh1 --setfencedaemon post_join_delay=25
Next, add a fence device. There are different types of fencing devices available. If you are using virtual machine to build a cluster, use
fence_virt device as shown below.

[root@rh1 ~]# ccs -h rh1 --addfencedev myfence agent=fence_virt
Next, add fencing method. After creating the fencing device, you need to created the fencing method and add the hosts to the fencing method.
[root@rh1 ~]# ccs -h rh1 --addmethod mthd1 rh1.mydomain.net
Method mthd1 added to rh1.mydomain.net.
[root@rh1 ~]# ccs -h rh1 --addmethod mthd1 rh2.mydomain.net
Method mthd1 added to rh2.mydomain.net.

Finally, associate fence device to the method created above as shown below:
[root@rh1 ~]# ccs -h rh1 --addfenceinst myfence rh1.mydomain.net mthd1
[root@rh1 ~]# ccs -h rh1 --addfenceinst myfence rh2.mydomain.net mthd1

8. cluster.conf File after Fencing

Your cluster.conf will look like below after the fencing devices, methods are added.
[root@rh1 ~]# cat /etc/cluster/cluster.conf
<?xml version="1.0"?>
<cluster config_version="10" name="mycluster">
<fence_daemon post_join_delay="25"/>
<clusternodes>
<clusternode name="rh1.mydomain.net" nodeid="1">
<fence>
<method name="mthd1">
<device name="myfence"/>
</method>
</fence>
</clusternode>
<clusternode name="rh2.mydomain.net" nodeid="2">
<fence>
<method name="mthd1">
<device name="myfence"/>
</method>
</fence>
</clusternode>
</clusternodes>
<cman/>
<fencedevices>
<fencedevice agent="fence_virt" name="myfence"/>

</fencedevices>
<rm>
<failoverdomains/>
<resources/>
</rm>
</cluster>

9. Types of Failover Domain

A failover domain is an ordered subset of cluster members to which a resource group or service may be bound.
The following are the different types of failover domains:
• Restricted failover-domain: Resource groups or service bound to the domain may only run on cluster members which are also members
of the failover domain. If no members of failover domain are availables, the resource group or service is placed in stopped state.
• Unrestricted failover-domain: Resource groups bound to this domain may run on all cluster members, but will run on a member of the
domain whenever one is available. This means that if a resource group is running outside of the domain and member of the domain
transitions online, the resource group or
• service will migrate to that cluster member.
• Ordered domain: Nodes in the ordered domain are assigned a priority level from 1-100. Priority 1 being highest and 100 being the
lowest. A node with the highest priority will run the resource group. The resource if it was running on node 2, will migrate to node 1
when it becomes online.
• Unordered domain: Members of the domain have no order of preference. Any member may run in the resource group. Resource group
will always migrate to members of their failover domain whenever possible.

10. Add a Filover Domain

To add a failover domain, execute the following command. In this example, I created domain named as “webserverdomain”,
[root@rh1 ~]# ccs -h rh1 --addfailoverdomain webserverdomain ordered
Once the failover domain is created, add both the nodes to the failover domain as shown below:
[root@rh1 ~]# ccs -h rh1 --addfailoverdomainnode webserverdomain rh1.mydomain.net priority=1
[root@rh1 ~]# ccs -h rh1 --addfailoverdomainnode webserverdomain rh2.mydomain.net priority=2
You can view all the nodes in the failover domain using the following command.
[root@rh1 ~]# ccs -h rh1 --lsfailoverdomain
webserverdomain: restricted=0, ordered=1, nofailback=0
rh1.mydomain.net: 1
rh2.mydomain.net: 2

11. Add Resources to Cluster

Now it is time to add a resources. This indicates the services that also should failover along with ip and filesystem when a node fails. For
example, the Apache webserver can be part of the failover in the Redhat Linux Cluster.
When you are ready to add resources, there are 2 ways you can do this.
You can add as global resources or add a resource directly to resource group or service.
The advantage of adding it as global resource is that if you want to add the resource to more than one service group you can just reference the global resource on your service or resource group. In this example, we added the filesystem on a shared storage as global resource and referenced it on the service.
[root@rh1 ~]# ccs –h rh1 --addresource fs name=web_fs device=/dev/cluster_vg/vol01 mountpoint=/var/www fstype=ext4
To add a service to the cluster, create a service and add the resource to the service.
[root@rh1 ~]# ccs -h rh1 --addservice webservice1 domain=webserverdomain recovery=relocate autostart=1
Now add the following lines in the cluster.conf for adding the resource references to the service. In this example, we also added failover IP to
our service.
<fs ref="web_fs"/>
<ip address="192.168.1.12" monitor_link="yes" sleeptime="10"/>

Friday, September 25, 2015

How to setup Local Repository Server from Disk image - Linvirtshell

Friday, September 25, 2015 0
Setup Local Repository Server from Disk image

1.First mount the OS image on server

# mount /dev/cdrom /mnt

2. Copy all the content to local directory

# cp -avf /mnt/* /var/ftp/pub/

3. Watch the size of /var/ftp/pub/ 

#watch du -h /var/ftp/pub

4. Un mount the image

#umount /mnt

5. Copy the grouping files to /root

# cp /var/ftp/pub/Server/repodata/comps-rhel5-server-core.xml /root
# cp /var/ftp/pub/VT/repodata/comps-rhel5-vt.xml /root

6. Remove the group files

# rm -rf /var/ftp/pub/Server/repodata
# rm -rf /var/ftp/pub/VT/repodata

7. Create new group Repository file

# createrepo -g /root/comps-rhel5-Server-core.xml -v /var/ftp/pub/Server
# createrepo -g /root/comps-rhel5-VT.xml -v /var/ftp/pub/VT

8. Remove the default repository files

# rm -rf /etc/yum.repos.d/*

9. Create new repository file (in server)

# vi /etc/yum.repos.d/server-repo

[Server]

name = RHEL SERVER
baseurl = file:///var/ftp/pub/Server
enabled = 1
gpgcheck =0

[VT]

name = RHEL VT
baseurl = file:///var/ftp/pub/VT
enabled = 1
gpgcheck = 0

10. Start the ftp service
#service vsftpd restart

Client Configuration

# vi /etc/yum.repos.d/client.repo

[Server]
name= Client Repo
baseurl = ftp://serverip/pub/Server
enabled = 1
gpgcheck = 0

[VT]
name= Client Repo
baseurl = ftp://serverip/pub/VT
enabled = 1
gpgcheck = 0

  Save and close the config. Run the below command for checking

#yum clean all
#yum list all

Wednesday, September 23, 2015

How to configure Software Raid on Linux?

Wednesday, September 23, 2015 0
Software RAID is one of the greatest feature in Linux to protect the data from disk failure.We have LVM also in Linux to configure mirrored volumes but Software RAID  recovery is much easier in disk failures compare to Linux LVM. I have seen some of the environments are configured with Software RAID and LVM (Volume groups are built using RAID devices).
Using simple md commands, we can easily add and remove the disks from RAID.

Supported Software RAID Configurations on Linux

RAID level      Description                                                    Linux Option
RAID 0           Stripping                                                    “–level=0 –raid-devices=3”
RAID 1           Mirroring                                                    “–level=mirror –raid-devices=2 “
RAID 5           Stripping with Distributed Parity.               “–level=5 –raid-devices=3”
RAID 6           Stripping with Distributed Double Parity    “–level=6 –raid-devices=4”
RAID 10         Mirrored Stripe.                                          “–level=10 –raid-devices=4”

Available Disks for configuring software RAID.
/dev/sdb
/dev/sdc

1.Label the disk with Software RAID tag:
Before configuring the software RAID,you have to label the disk properly using fdisk command.So that you can easily identify which disks are in RAID and ioctl can read the disk properly.
[root@Test ~]# fdisk /dev/sdb

Create New Partition (n) with Primary (P) Select the size. Set the code fd for software raid and save the configuration
Perform the same for disk /dev/sdc as well. 

Run Partprobe command

2.Verify the both disk flag status using fdisk command.
[root@Test ~]# fdisk -l /dev/sdb /dev/sdc

3.Configure the desired RAID level.Here i am configuring RAID 1.
[root@Test ~]# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

4.Create filesystem on md device and mount it.Do not forget to add the device details in
/etc/fstab to mount the volume across the system reboot.
[root@Test ~]# mkfs.ext4 /dev/md0
[root@Test ~]# mkdir /Test1
[root@Test ~]# mount /dev/md0 /Test1/
[root@Test ~]# df -h /Test1/

5.If you want to use md device on LVM, then skip “step 4” and continue from here.
You can add the logical volume details in /etc/fstab to mount the volume across the reboots.
[root@Test ~]# pvcreate /dev/md0
[root@Test ~]# pvs
[root@Test ~]# vgcreate raidvg /dev/md0
[root@Test ~]# lvcreate -L 200M -n lvdata raidvg
[root@Test ~]# lvs |grep lvdata

[root@Test ~]# mkfs.ext4 /dev/raidvg/lvdata
[root@Test ~]# mount /dev/raidvg/lvdata /Test1
[root@Test ~]# df -h /Test1


6. Check the raid status
[root@Test ~]# cat /proc/mdstat

7. mdadm configuration file is /etc/mdadm.conf


8. You have to update mdadm.conf with newly configured RAID information using below method
[root@Test ~]# mdadm --examine --scan
[root@Test ~]# mdadm --examine --scan >> /etc/mdadm.conf
[root@Test ~]# cat /etc/mdadm.conf

9.To see Configured RAID information,use below commands.
[root@Test ~]# mdadm --query /dev/md0
[root@Test ~]# mdadm --detail /dev/md0

10. If you want remove the software RAID, use the below methods.First stop the RAID using madadm command.Once its stopped ,you can remove the super block to destroy complete RAID configuration from the configured disks.

[root@Test ~]# mdadm --stop /dev/md0
[root@Test ~]# mdadm --query /dev/md0
[root@Test ~]# mdadm --zero-superblock /dev/sdb1
[root@Test ~]# mdadm --zero-superblock /dev/sdc1
[root@Test ~]# watch cat /proc/mdstat

Friday, September 18, 2015

How to scan a new LUN added to Redhat linux server

Friday, September 18, 2015 0
Scan the new LUN in RHEL server.

Here echo command is used scan the newly added LUN in Linux server (RHEL)

SCSI_HOST

# echo "- - -" > /sys/class/scsi_host/hostx/scan

or

# echo "c t l" >  /sys/class/scsi_host/hostx/scan

FC_HOST

# echo "1" > /sys/class/fc_host/hostX/issue_lip
# echo "- - -" > /sys/class/scsi_host/hostx/scan

c   - channel on the HBA,
t   - SCSI target ID  ,
l   - LUN 
x   - HBA number

Hope it helps.

How to download a large file on a Linux Server or Desktop?

Friday, September 18, 2015 0
Run wget In Background For Downloading Files on a Linux Server or Desktop

Syntax
wget -bqc http://path-to-url/linux.iso

You will see a PID on screen:

-b: Go to background immediately after start up. If no output file is specified via the -o, output is redirected to wget-log.
-q : Turn off Wget’s output and save disk space.
-c : Resume broken download i.e. continue getting a partially-downloaded file. This is useful when you want to finish up a
download started by a previous instance of Wget, or by another program.

This tip will save your time while downloading large ISO file or any other files from the Internet

The nohup command

You can also use the nohup command to execute commands after you exit from a shell prompt. The syntax is:
$ nohup wget -qc http://path-to-url/linux.iso &
$ exit

Tuesday, September 15, 2015

RHEL: Linux Bonding / Teaming Multiple Network Interfaces (NIC) Into a Single Interface

Tuesday, September 15, 2015 0
Step #1: Create a Bond0 Configuration File

Red Hat Enterprise Linux (and CentOS) stores network configuration in /etc/sysconfig/network-scripts/ directory.
First, you need to create a bond0 config file as follows:

# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Append the following linest:
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

Replace IP address with your actual setup. Save and close the file.

Step #2: Modify eth0 and eth1 config files Open both configuration using a text editor such as vi/vim, and make sure file read as follows for eth0 interface

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Modify/append directive as follows:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Open eth1 configuration file using vi text editor, enter:

# vi /etc/sysconfig/network-scripts/ifcfg-eth1

Make sure file read as follows for eth1 interface:
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Save and close the file.

Step # 3: Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. Modify kernel modules configuration file:

# vi /etc/modprobe.conf

Append following two lines:
alias bond0 bonding
options bond0 mode=balance-alb miimon=100

 **********************************************************

Below are list of modes used in Network Bonding :

    balance-rr or 0 – round-robin mode for fault tolerance and load balancing.
    active-backup or 1 – Sets active-backup mode for fault tolerance.
    balance-xor or 2 – Sets an XOR (exclusive-or) mode for fault tolerance and load balancing.
    broadcast or 3 – Sets a broadcast mode for fault tolerance. All transmissions are sent on all slave interfaces.
    802.3ad or 4 – Sets an IEEE 802.3ad dynamic link aggregation mode. Creates aggregation groups that share the same
    speed & duplex settings.
    balance-tlb or 5 – Sets a Transmit Load Balancing (TLB) mode for fault tolerance & load balancing.
    balance-alb or 6 – Sets an Active Load Balancing (ALB) mode for fault tolerance & load balancing

************************************************************

Save file and exit to shell prompt. You can learn more about all bounding options by clicking here).

Step # 4: Test configuration

First, load the bonding module, enter:
# modprobe bonding

Restart the networking service in order to bring up bond0 interface, enter:
# service network restart

Make sure everything is working. Type the following cat command to query the current status of Linux kernel bounding driver, enter:

# cat /proc/net/bonding/bond0

Sample outputs:

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63

To list all network interfaces, enter:
# ifconfig

Sample outputs:

bond0     Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
 RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:250825 (244.9 KiB)  TX bytes:244683 (238.9 KiB)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:251161 (245.2 KiB)  TX bytes:180289 (176.0 KiB)
 Interrupt:11 Base address:0x1400
eth1      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:4 errors:0 dropped:0 overruns:0 frame:0
 TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:258 (258.0 b)  TX bytes:66516 (64.9 KiB)
 Interrupt:10 Base address:0x1480

Monday, September 14, 2015

Basic Linux Interview Questions and Answers - Linvirtshell

Monday, September 14, 2015 0
1. Explain in detail the Linux booting procedure
  • When a Linux machine is powered on BIOS loads up first.
  • It will prompt you to select boot device which can be Hard disk, CD-ROM, Floppy drive, Network etc.
  • By default generally it will boot with hard disk Next comes your MBR.
  • This will load and execute the GRUB boot loader menu.
  • GRUB stands for Grand Unified Boot Loader.
  • This will display the a splash screen with the contents of /boot/grub/grub.conf.
  • List of available and installed kernels will be shown, if not selected default kernel will be loaded
  • Kernel: Mounts the root files system as specified by "root=" parameter inside /boot/grub/grub.conf file
  • Next it will execute /sbin/init program which will boot the linux machine in the default run level as specified by /etc/inittab
  • Runlevel: All the scripts loaded inside the selected runlevel from step 5 will be executed These scripts are placed inside /etc/rc.d/rcx.d/. Here x is the runlevel value which will be varying from 0-6
  • Scripts starting from S would load at startup and those starting with K would kill the process at shutdown.
  • These incident will take place as per the numerical value assigned to them. For eg: s13network will load prior than s15 sendmail
  • Next your login screen will come up
2. What is the difference between soft link and hard link?
    Soft Link

  • Using this only a link to the original file is created (shortcut).
  • The size of created shortcut is null.
  • If you delete the file then the created link (shortcut) won't work.
  • In case you delete the shortcut link then it won't affect the original file
    Hard Link
  • Another copy of the file is created.
  • Both the file have same inode no.
  • Any changes made in either of the file will appear on the other file.
  • Deleting any of the one file won't affect the other file.
3. How to find the bit size of your Linux machine?
    # uname -m
    # getconf LONG_BIT

4. How can you add a banner or login message in Linux?
By editing these two files

    /etc/issue
    /etc/motd

5. How will you check the release version of your Linux machine?
    # cat /etc/redhat-release

6. What is the difference between normal kernel and kernel-PAE?
    kernel in 32 bit machine supports max of 4 GB RAM whereas
    kernel PAE in 32 bit linux machine supports till 64 GB RAM

7. Tell me the command to find all the commands in your linux machine having only 2 words like ls, cp, cd etc.
    # find /bin /sbin/usr/bin /usr/sbin -name ?? -type f

8. Which file is generally used to configure kickstart?
    anaconda.cfg

9. What is the command use to compress a dir using gzip compression?
    # tar -czvf myfil.tar.gzip orig_file

10. What is the command use to compress a dir using bzip2 compression?
    # tar -cjvf myfil.tar.bzip2 orig_file

11. Which log file will you check for all authentication related messages?
    /var/log/secure

12. What is the command to create multiple directories using one command?
      Using -p argument along with mkdir command

13. What is the command used to find the process responsible for a particular running file?
      # fuser -m filename
      # lsof filename

14. What are the three values shown in load average section of top command?
       It shows the current, 5 min back and 15 min back load average value

15. How to check all the process running by a particular user?
        # ps -u username

16. What is an orphan process?
       An orphan process is a process that is still executing, but whose parent has died.

17. How to remove the package without checking the dependencies on Redhat Linux ?
      rpm -ev –nodeps package_name

18. What is the command in sar to monitor NIC devices received/transmitted packets?
      # sar -n DEV 1 5

19. How to enable SAR command to store data for more then a month?
      #/etc/sysconfig/sysstat - Here change the History = 30 days and sar will start storing the data for months.

20. What is ACL?

    #Requiremnet to use ACL - A file system should be mounted with ACL option.
    #ACL allows us to give permssion to someone without change the actual permission of   the file.
    # setfacl -m file:rwx -u User

21. How to allow specfic user to login via SSH?
    #AllowUsers anze dasa kimy in /etc/sshd/ssh.conf

22. how to create a new partition and add to swap?
    #create new parttion with fdisk and mark the partition type as 83
    #mkswap /dev/sdaX
    #swapon /dev/sdaX

23. How to get the list of dependencies for specific rpm file ?
    rpm -qpR rpm_file

24. How to get the list of dependencies for specific package ?
    rpm -qR package_name 

Linux Interview Questions and Answers for Freshers - Linvirtshell

Monday, September 14, 2015 0
1. What is Network Bonding ?

    Network bonding is the aggregation of multiple Lan cards into a single bonded interface to provide fault toleranceand high performance.
    Network bonding is also known as NIC Teaming

2. Mention all the network configuration files you would check to configure your ethernet card

    /etc/sysconfig/network-scripts/ifcfg-eth*
    /etc/sysconfig/network
    /etc/resolv.conf
    /etc/nsswitch.conf

3. How to change the ethernet card setting

    ethtool -s ethX speed 1000 duplex full

4. What does the last two sections define in fstab file?

    The 5th column tells the dump information if whether the partition has to be backed up. It it is "0" the filesystem will be ignored.
    The 6th column tells the order in which fsck command would check the filesystem on boot. If it is "0" then fsck won't check the filesystem.

5. How to add & change the Kernel parameters ?

    To Set the kernel parameters in linux , first edit the file ‘/etc/sysctl.conf’ after making the changes save the file and run the command ‘sysctl -p’ , this command will make the changes permanently without rebooting the machine.

6. What is the difference between TCP and UDP protocol?

    TCP is a connection oriented protocol and contain the information of sender as well as receiver.

Eg: HTTP.FTP, Telnet

TCP is slower than UDP due to its error checking mechanism

    UDP protocols are connection less packets have no information to where they are going. These type of ports are generally used for broadcasting.For eg: DNS, DHCPUDP are faster

7. What are the possible ways to check if your system is listening to port 67

# fuser -v -n tcp 67
# cat < /dev/tcp/localhost/67
# ssh -vv localhost:67
# lsof -i :67
# nmap localhost | grep 67
# netstat -ntlp | grep 67
# telnet localhost 67

8. What is umask?

    In computing, umask is a command that determines the settings of a mask that controls which file permissions are set for files and directories when they are created. It also refers to a function that sets the mask, and to the mask itself,
    which is formally known as the file mode creation mask.

9. What is the default umask value for useradd command and where is it defined?

    Default umask value for useradd: 077
    /etc/login.defs

10. Will you be able to cd into a directory with only read permission?

    No, we need execute permission along with read to cd into directory

11. What is -R argument used for along with chmod command?

    To recursively apply the permission to all the directories including sub directories and files

12. How can you restrict a normal as well as root user from making any changes as well as deleting any file?

    chattr command

13. How do you give acl in Linux?

    Give individual permission using setfacl