Monday, December 21, 2015

Difference between EXT2, EXT3,EXT4

Features EXT2 Second extended file system EXT3 Third extended filesystem EXT4 Fourth extended file system
Developer(s) Rémy Card Stephen Tweedie Mingming Cao, Andreas Dilger, Alex Zhuravlev, others
File allocation bitmap (free space), table (metadata) bitmap (free space), table (metadata) Extents/Bitmap
Max. volume size 2–32 TiB 4 TiB – 32 TiB 1 EiB
Max. file size 16 GiB – 2 TiB 16 GiB – 2 TiB 16 TiB (for 4k block filesystem)
Max. number of files 1018 Variable, allocated at creation time 4 billion (specified at filesystem creation time)
Max. file name length 255 bytes 255 bytes 255 bytes
Allowed characters in file names All bytes except NUL ('\0') and '/' All bytes except NUL ('\0') and '/' All bytes except NUL ('\0') and '/' and the special file names "." and ".."
Date range December 14, 1901 - January 18, 2038 December 14, 1901 – January 18, 2038 14 December 1901 - 25 April 2514
Supported operating systems Linux, BSD, Windows (through an IFS), Mac OS X Linux, BSD, Windows (through an IFS) Linux
FreeBSD (read-only with ext4fuse)
Mac OS X (read-only with ext4fuse, full with ExtFS)
Windows (Read/Write without journaling with ext2fsd)

Difference between LVM1 and LVM2

Features LVM1 LVM2
RHEL 3 support YES NO
RHEL 4 support NO YES
Transactional metadata for fast recovery NO YES
Shared volume mounts with GFS NO YES
Cluster Suite failover supported    YES YES
Striped volume expansion NO YES
Max number PVs 256 PVs 2**32 PVs (4294967296)
Max number LVs 256 LVs 2**32 PVs    (4294967296)
Max device size 2 Terabytes 8 Exabytes (64-bit CPUs)
Volume mirroring support NO YES

Sunday, December 13, 2015

AWK Commands for Linux

1: Field/text processor
2: Default Field-delimiter is white-space.
3: Stores fields (columns) into tokens, which then become accessible during processing
4: Will accept input from: file or STDIN or pipe


Commands:

1: To print each line in its entirety.
# awk '{ print $0 }' test.txt
2: To print column #1 from each line.
# awk '{print $1}' test.txt
3: To print column #2 from each line.
# awk '{print $2}' test.txt
4: To print column #1 then #2.
# awk'{print $2,$1}' test.txt
5: To print all columns where line includes 'Red'.
# awk'/Red/ {print $0}' test.txt
6: To print column #1,#2,#3 where line include 'Red'.
# awk '/Red/ {print $1, "-",$2,"-",$3}' test.txt
7: To print all columns of records containing '2012' in the second column.
# awk '{if ($2 ~ /2012/) print $0}' test.txt
8: To print lines ending in : 2012.
# awk '/2012$/ {print $0}' test.txt
9: Accept a pipe using above point 8 commands.
# grep 2012 /var/log/messages | awk '/2012/ {print $0}'
10: To print columns $3-$6 where column 2 = '9'.
# awk '{if ($2 ~ /9/) print $3,$4,$5,$6}' /var/log/message

Wednesday, December 9, 2015

Most useful find commands for Linux SystemAdmin.

1 : Search the file aaa from current directory downwards and print it.

# find . -name aaa - print

2 : Find all files which begin with 'a' or 'b' from current directory.

# find . -name [ab]* -print

3 : Search directories called backup from /usr directory.

# find /usr -type d -name backup -print

4 : Search normal files called backup from /usr directory.

# find /usr -type f -name backup -print

5 : Search character special files called backup from /usr directory.

# find /usr -type c -name backup -print

6 : Search block special files called backup from /usr directory

# find /usr -type b -name backup -print

7 : Search all directories from /usr whose inode number is 1235 and print them.

# find /usr -inum 1235 -print

8 : Search in root directory for all files which have less than 2 links.

# find / -links -2 -print

9 : Search in current directory for all files whose owner is abc1 and group is grp1.

# find . \(-user abc1 -a -group grp1 \) -print

10 : Search in current directory for all files whose owner is abc1 or whose name is myfile1.

# find . \(-user abc1 -o -name myfile1 \) -print

11 : Search in current directory for all files which have permissions 777.

# find . -perm 777 -print

12 : Search in current directory for all files chose size is 10 blocks.

# find . -size 10 -print

13 : Search in current directory for all files whose size  10 bytes(characters).

# find . -size 10c -print

14 : Search in current directory for all files whose size is greater than 10 byets.

# find . -size +10c -print

15 : Search in current directory for all files which were accessed exactly 7 days back.

# find . -atime 7 -print

16 : Search in current directory for all files which have not been accessed since last 7 days (or in other words which were accessed more than 7 days ago.)

# find . -atime +7 -print

17 : Search in current directory for all files which have not been modified since last 7 days (or in other words which have been modified more than 7 days ago.)

# find . -mtime +7 -print

18 : Search in current directory for all files whose status has changed (on creation or modification ) more than 7 days ago.

# find . -ctime +7 -print

19 : Search in current directory for all files whose name is cog and instead of printing their names executes a command rm on the searched files.

# find . -name cog -exec rm {} \;

Here, the {} indicate that the searched files would become arguments for rm.The semicolon is necessary and it has to be preceded by a \ to take away its special meaning.

20 : Same as above except that this time it should ask for confirmation before executing rm command.

# find . -name cog -ok rm {} \;


Tuesday, December 8, 2015

How to configure audit to monitor file deletion in Red Hat Enterprise Linux?

Issue:
What rules can be created to monitor file deletion operation.

Solution:
Add these two entry in  /etc/audit/audit.rules .


# vi /etc/audit/audit.rules

-a always,exit -F arch=b32 -S unlink -S unlinkat -S rename -S renameat -k delete
-a always,exit -F arch=b64 -S unlink -S unlinkat -S rename -S renameat -k delete


After writing the rules, restart the service auditd and make it on in to retain across reboot.

# /etc/init.d/auditd restart
# chkconfig auditd on

Now for testing create a file and delete it same time.

# touc testing
# rm -rf testing

Trace the log from below path.

# tail -f /var/log/audit/audit.log

How to restore a deleted volume group ?

Issue:

1. Unable to find the volume group, even though all devices are present.
2. LVM metadata has been deleted.


Solution:

Always there is a backup of metadata before and after running any LVM on a PV/VG/LV. which is allways taken by LVM.

Backup location is /etc/lvm/archive/ (the copies taken before executing a command) and in /etc/lvm/backup (copies taken after executing a command).
Also you can find the backup file using vgcfgrestore command.
 
# vgcfgrestore --list   <Volume-Group-Name>

# vgcfgrestore --list geo-vg

Ouput:

# data-vg_00_00000-16736.vg

Using the vgcfgrestore command metadata can be written back to the devices belonging to that volume Group which found from backup.

# vgcfgrestore -f /etc/lvm/archive/<file-name> <Voulme-Group-Name>

Example:

# vgcfgrestore -f /etc/lvm/archive/geo-vg_00_00000-16736.vg  geo-vg

Output:

# Restored volume group geo-vg

Monday, December 7, 2015

How to remove user list from GUI login in RHEL 6.3

Issue

Disable user list from login screen.







Solution

Run below command in terminal login as root.


# gconftool-2 –direct –config-source xml:readwrite:/etc/gconf/gconf.xml.defaults –type bool –set /apps/gdm/simple-greeter/disable_user_list true