Disable ping responses from my system?

To configure a Red Hat Enterprise Linux system to not respond to a ICMP (ping), run the following command as the root user.

echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
 
To make the changes persistent across reboots, add the following line to your /etc/sysctl.conf file.

# Ignore all to ICMP (ping)
net.ipv4.icmp_echo_ignore_all = 1

Disabling IPv6 support in Red Hat Enterprise Linux 7

Disable ipv6 built-in kernel module.
  1. Edit /etc/default/grub and append ipv6.disable=1 to GRUB_CMDLINE_LINUX like the following sample:
    GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/swap 
      crashkernel=auto rd.lvm.lv=rhel/root ipv6.disable=1"
    
  2. Run the grub2-mkconfig command to regenerate the grub.cfg file:
    # grub2-mkconfig -o /boot/grub2/grub.cfg
    
    Alternatively, on UEFI systems, run the following:
    # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
    
  3. Reboot the system to disable IPv6 support.

How to change MTU size for bonding interface

Environment

  • Red Hat Enterprise Linux (All Versions)

Issue

  • To set MTU for a bond interface, is there a need to change MTU in all slave interface configuration files ? Or is changing the configuration of the bond enough ?

Resolution

  • The MTU need only be set on the bond device. This will be propagated to the slave interfaces.
  • To make the setting permanent for bondX, edit the configuration file /etc/sysconfig/network-scripts/ifcfg-bondX and add the following line:
MTU=<value>
  • Then, restart the network service:
# service network restart
[root@rhel7 ~]# grep MTU /etc/sysconfig/network-scripts/ifcfg-*
/etc/sysconfig/network-scripts/ifcfg-bond0:MTU="9000"
/etc/sysconfig/network-scripts/ifcfg-eth0:MTU="9000"
/etc/sysconfig/network-scripts/ifcfg-eth1:MTU="9000"

[root@rhel7 ~]# systemctl restart network.service

[root@rhel7 ~]# ip addr show
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 52:54:00:41:c1:4a brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 52:54:00:41:c1:4a brd ff:ff:ff:ff:ff:ff
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP 
    link/ether 52:54:00:41:c1:4a brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.136/24 brd 192.168.122.255 scope global bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe41:c14a/64 scope link tentative dadfailed 
       valid_lft forever preferred_lft forever

Diagnostic Steps

  • Check MTU values in output of command ifconfig -a.

lvremove failed with error " Logical volume vgname/lvname contains a filesystem in use."

Environment

  • Red Hat Enterprise Linux 6

Issue

  • Not able to remove unounted logical volume.
  • lvremove failed with below error.
# lvremove /dev/mapper/testvg-testlv
  Logical volume testvg-testlv contains a filesystem in use.

Resolution

  • Stop nfs service and remove logical volume.
  • Check whether there are any processes which are accessing the logical volume. In some cases kernel thread for journald might be accessing the LVM device due to which the lvm can be left open. In such case rebooting the server is the safest way to recover since the journald process should not be killed.

Root Cause

  • Mount point was exported through nfs.

Diagnostic Steps

1. Verify filesystem is not mounted.
# df 
# cat /proc/mount
2. verify no process in lsof/fuser is holdering this lv or mount point.
3. Verify whether this lv is exported through nfs
#cat /etc/exportfs
4. Try to to flush block device and drop cache
# blockdev --flushbufs /dev/vg/lv
# echo 1 > /proc/sys/vm/drop_caches
# echo 2 > /proc/sys/vm/drop_caches
# echo 3 > /proc/sys/vm/drop_caches

How to change time zone from command line on RHEL 7 ?

How to change time zone from command line on RHEL 7 ?

Environment

  • Red Hat Enterprise Linux 7

Issue

  • How to change time zone from command line on RHEL 7 ?

Resolution

On RHEL7,there is a different way for us to change time zone.
  1. Find the desired time zone with the below command or we can use the command "tzselect" to find the desired time zone..Let's make "Asia/Shanghai" as an example.
    # timedatectl list-timezones
    
  2. Change the time zone.
    # timedatectl set-timezone Asia/Shanghai
    
  3. Verify the status of time zone.
    # timedatectl status
    

Root Cause

timedatectl is a new feature on RHEL7. It may be used to query and change the system clock and its settings. See more at man timedatectl or Changing the Time Zone

RHCE-Interview Question || LVM02



Part-02

6. How to reduce the File system size in Linux?

Step1:- unmounts the file system
Step2:- we need to reduce the file system size using "resize2fs"
Step3:-Then reduce the lv0 size using "lvreduce"
#umount –l /dev/VG0/LV0
#resize2fs -f /dev/VG0/LV0  3G
#lvreduce -L 3G /dev/VG0/LV0

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

8.How to extent the volume group ?
Using “vgextend” we can increase the volume group.

9.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 SAN team.(/dev/sdd)
      2.Create physcical volume ( # pvcreate /dev/sdd )
      2.Extend the volume group (# vgextend vg02 /dev/sdd)

10.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/”

11. How to stop the logical volume? or deactivate the logical volume ?
Answer: “lvchange -an /dev/vg_name/lv_name”

12.How to activated the logical volume which in deactivated state ?
Answer: “lvchange -ay /dev/vg_name/lv_name” .

13. How to disable the volume group ? or Deactivate the volume group ?
#vgchange -an vg_name

14.How to enable the volume group? or Activate the volume group?
#vgchange -ay vg_name


15.How do you find that what are the disks are used for  logical volume mirroring ? 

Answer: use “lvs -a -o +devices”

16.How to rename volume Group ? can we rename the VG on fly ? 

It’s possible to rename the volume group on flying mode.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.

17. How to take a LVM configuration backup?

Use (#vgcfgbackup vg_name) to take the latest configuration backup of volume group. The default volume group backup location is “/etc/lvm/backup”.

18. How to re-create the device files for LVM volumes ?
Run “vgmknodes” to recreate the LVM devices files.

19. What is lvmdump? 
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


 20:Explain LVM snapshot?
LVM snapshots allow the administrator to create a new block device which presents an exact copy of a logical volume, frozen at some point in time.

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


abrt-server is showing .lock file is locked by a specific process

Environment

  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7

Issue

  • The following message is seen in /var/log/messages:
abrt-server[28388]: Lock file '.lock' is locked by process 35522

Resolution

RHEL 6
  • In Red Hat Enterprise Linux 6 this issue has been resolved in Errata with package abrt-2.0.8-40.el6.x86_64.rpm.
RHEL 7
  • In Red Hat Enterprise Linux 7 this issue has been resolved in Errata with package abrt-2.1.11-45.el7.x86_64.rpm.
  • There are instances where the issue persisted in the 2.1.11-50.el7 version of ABRT.
    There is a Bug reported and is being worked on.

Diagnostic Steps

  • Check /var/log/messages for abrt-server[<pid>]: Lock file '.lock' is locked by process <pid>

When change or login to specific user, 'abrt-cli status' timed out is always shown



Environment

  • Red Hat Enterprise Linux 7.3
  • abrt-2.1.11-45.el7.x86_64

Issue

  • When change or login to specific user, 'abrt-cli status' timed out is always shown
# su - testuser
Last login: Mon Jun 12 15:00:40 JST 2017 from localhost on pts/0
'abrt-cli status' timed out

Resolution

  • Since lastnotification file is not owned by testuser the user can't update the file. Usually, the file is updated when change or login to the user, and it records the latest time.
  • If the system has a large quantity of abrt status information and it takes over 10 sec, the time out message will be shown every time.
  • To prevent it, correct the file permission, so that the file can be updated. Once the file is updated, time out message should not be shown.
# chown testuser lastnotification

Diagnostic Steps

 [root@server01:~]# cat /etc/passwd |grep testuser
testuser:x:6014:4500::/home/testuser:/bin/bash
[root@server01:~]# ls -la /home/testuser/
total 28
drwxrwx--- 7 testuser group1  206  Jun  9 14:12 .
drwxr-xr-x 4 root     root     37  May 26 14:27 ..
-rw------- 1 user001  group1 1739  Jun  9 16:52 .bash_history
-rw-r--r-- 1 testuser group1   18  Jul 13  2016 .bash_logout
-rw-r--r-- 1 testuser group1  193  Jul 13  2016 .bash_profile
-rw-r--r-- 1 testuser group1  338  May 11 18:37 .bashrc
drwxr-xr-x 3 user001  group1   18  Jun  1 16:21 .cache
drwxr-xr-x 3 user001  group1   18  Jun  1 16:21 .config
-rw-r--r-- 1 testuser group1  172  Apr 28  2016 .kshrc
-rw------- 1 e225675  group1    3  Jun  9 14:12 .psql_history
drwxr-xr-x 3 user001  group1   65  Jun  5 14:43 .subversion
drwxrwxrwx 5 root     root    174  Jun  1 19:20 dir_20170601
drwxrwxrwx 3 root     root   4096  Jun  2 14:03 dir_20170602
[root@server01:~]#
[root@server01:~]# ls -la /home/testuser/.cache/abrt/
total 4
drwxr-xr-x 2 user001 group1 30  Jun  9 16:44 .
drwxr-xr-x 3 user001 group1 18  Jun  1 16:21 ..
-rw------- 1 user001 group1 11  Jun  9 16:44 lastnotification

How can I find the installation date of my Red Hat Enterprise Linux system ?

==>Environment

Red Hat Enterprise Linux 3 / 4 / 5/ 6

==>Issue

How can I find the installation date of my Red Hat Enterprise Linux system?

==>Resolution

There are various method by which you can find when your system was installed.

One method is to get the package details of the "basesystem" package:

# rpm -qi basesystem

In the output you can see the installation date:

Install Date: Wed 07 Jan 2009 04:23:27 AM IST

The "basesystem" rpm defines the components of a basic Red Hat Enterprise Linux system (for example, the package installation order to use during
bootstrapping). This rpm does not provide any files. Basesystem should be the first package installed on a system and it should never be removed.

Since this package is never removed or updated , the install date of this package indicates the install date of the system.

Other methods include checking the creation date of the files "install.log" in the /root directory or "anaconda.*" logs in the /var/log directory:

# ls -l /root/install.log
# ls -l /var/log/anaconda.*

But since these files can be accidentally deleted, finding the installation date can be best accomplished using the "basesystem" rpm.