Saturday, 25 February 2017

RHEL7 installation Kickstart File

I have made Kickstart (Auto Answer File) Using Kcikstart configuration generator tool with LVM partitioning included

[root@ArkIT ~]#cat ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$tS7oWXXF$X.HS5njtcfPpxHgW9pFtX.
# System timezone
timezone Africa/Abidjan
# Use network installation
url --url="http://192.168.4.27/rhel7"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=eth0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled

# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
volgroup rhel --pesize=4096 PV0
part PV0 --fstype=lvmpv --ondisk=sda --size=50000
part /boot --fstype=xfs --size=500
logvol / --vgname=rhel --name=root --fstype=xfs --size=10000
logvol /var --vgname=rhel --name=var --fstype=xfs --size=8000
logvol swap --vgname=rhel --name=swap --fstype=swap --size=8000
logvol /home --vgname=rhel --name=home --fstype=xfs --size=7000
logvol /usr --vgname=rhel --name=usr --fstype=xfs --size=7000

%packages
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@mariadb
@multimedia
@print-client
@x11
kexec-tools

%end

%post
useradd ravi
echo password | passwd ravi
%end

Thursday, 19 January 2017

A Major Difference Between RHEL 6 vs RHEL 7 Here you go

RHEL 7 vs RHEL 6

Red Hat Enterprise Linux 7 is an Light weight and minimized Operating system. RHEL 7 changes are huge effect to enterprise.

Let's see what changed in RHEL 7 as per administration prospective.

  • First one is Anaconda Installer Completely new.
  • Grub version updated from 0.97 to Grub 2 fast booting
  • Procedure of bypassing root password at booting process completely different than RHEL 6/5 
  • There is no SysV Initd in RHEL 7 it's an new Systemd
  • Run Levels are changed to Targets.
  • Default file system in RHEL 7 is XFS. XFS file system supports 550TB of each partition size in 64-bit.
  • Directories /bin /sbin /lib and /lib64 are moved under /usr/
  • Network Interface Names are changed from eth0 to ens.xxx
  • New concept to create multiple profiles top of one Ethernet card, No need of changing IP addresses and settings every time when you connect different networks, simply activate different profile.
  • GNOME version changed from 2 to 3
  • No classic registration system, completely changed to Red Hat subscription Manager
  • Default database is MariaDB instead of MySQL
  • Cluster Manager has been changed to Pacemaker and Corosync
  • Ifconfig command is deprecated, replaced with ip command
  •  User Identification Numbers (UID's) changed from 500 to 1000, which means when you create new normal user in RHEL 7 will get UID from 1000 to 65534
  • locate command is changed to mlocate
  •  yum commands are changed little bit

 
Feature Name RHEL 6  RHEL 7
Default File System Ext4 XFS
Kernel Version 2.6.xx 3.10.xx
Release Name Santiago Maipo
Gnome Version GNOME 2 GNOME 3.8
KDE Version 4.6 4.1
Release Date 10-Nov-10 10-Jun-14
NFS Version NFS 4 NFS 4.1. NFS V2 is deprecated in RHEL 7
Samba Version 3.6 4.4
Default Database MariaDB MySQL
Cluster Resource Manager Rgmanager Pacemaker
Network Grouping Team Driver will support multiple types of Teaming methods called Active-Backup, Load-balancing and Broadcase Bonding can be done as Active-Backup, XOR, IEEE and Loac Balancing
KDUMP RHEL 7 can be supported up to 3TB Kdump does't support with large RAM Size
Boot Loader Grub 2
/boot/grub2/grub.cfg
Grub 0.97
 /boot/grub/grub.conf
File System Check xfs_replair
- Inode blockmap checks
-Inode allocation map checks
-Inode size check
-Directory check
-Path Name check
-Link count check
-Freemap check
-Super block check
e2fsck
-Inode check. Block and size check
--Directory Structure check
-Directory Link Check
-reference count check
-Group Summary Check
Process ID Systemd (1) Initd (1)
Port Security Firewalld instead of iptables. Iptables can also support with RHEL 7, but we can't use both of them at the same time. Firewall will not allow any port until and unless you enabled it. iptables by default service port is enabled when service is switched on.
Boot Time 40 Sec 20 Sec
File System Size EXT4 16TB with XFS 100TB XFS 500TB with EXT4 16TB
Processor Architecture 32Bit and 64Bit Only 64Bit.
Network Configuration Tool steup nmtui
Hostname Config File /etc/sysconfig/network /etc/hostname No need to edit hostname file to write permanent hostname simply use hostnamectl command
Interface Name eth0 ens33xxx
Managing Services service sshd start
service sshd restart
chkconfig sshd on
systemctl start sshd.service
systemctl restart sshd.service
systemctl enable sshd.service
System Logs /var/log/ /var/log
journalctl
Run Levels runlevel 0 - Power Off
runlevel 1 - Single User Mode
runlevel 2 - Multi User without Networking
runlevel 3 - Multi User CLI
runlevel 4 - Not USed
runlevel 5 - GUI Mode
runlevel 6 - Restart
There is no run levels in RHEL 6. Run levels are called as targets
Poweroff.target
rescue.target
multi-user.target
graphical.target
reboot.target
UID Information Normal User UID will start from 500 to 65534
System Users UID will start from 1 to 499
Normal User UID start from 1000 - 65534
System Users UID will start from 1 to 999

Because Services are increased compare to RHEL 6
By Pass Root Password Prompt append 1 or s or init=/bin/bash to Kernel command line Append rd.break or init=/bin/bash to kernel command line
Rebooting and Poweroff poweroff - init 0
reboot - init 6
systemctl poweroff
systemctl reboot
YUM Commands yum groupinstall
yum groupinfo
yum group install
yum group info

Thanks, please provide your valuable feedback on the same.
 

Thursday, 15 September 2016

ReviewBoard Complete Installation Guide Ubuntu

ReviewBoard Installation and configuration to review the developers code. 

# apt-get install openssh-server
# service ssh restart
# apt-get install python-setuptools
# apt-get install python-setuptools
# easy_install -U setuptools
# apt-get install python-dev
# apt-get install memcached
# easy_install python-memcached
# apt-get install patch
# easy_install ReviewBoard
# sudo apt-get install python-cffi
# sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev libffi-dev
# easy_install ReviewBoard
# sudo apt-get install zlib1g-dev libxml2-dev libxslt1-dev
# easy_install ReviewBoard
# apt-get install libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev
# easy_install ReviewBoard
# easy_install mysql-python
# apt-get install python-mysqldb
# easy_install mysql-python
# apt-get install mysql-server
# apt-get install python-mysqldb
# easy_install mysql-python
# apt-get install libmysqlclient-dev
# easy_install mysql-python
# easy_install psycopg2

# apt-get install libpq-dev
# easy_install psycopg2
# apt-get install cvs
# apt-get install git-core
# easy_install mercurial
# apt-get install pip
# easy_install pip
# pip install p4python
# easy_install mercurial
# apt-get install subversion python-svn
# apt-get install python-subvertpy
# easy_install subvertpy
# easy_install django-storages
# easy_install django-storage-swift
# easy_install nose Sphinx
# apt-get install apache*
# service apache2 restart
# service apache2 status
# vi /etc/mysql/my.cnf
# mysql -u root -p
# rb-site install /var/www/html/reviewboard1
# chown -R www-data /var/www/html/reviewboard1/htdocs/media/uploaded
# chown -R www-data /var/www/html/reviewboard1/htdocs/media/ext
# chown -R www-data /var/www/html/reviewboard1/htdocs/static/ext
# chown -R www-data /var/www/html/reviewboard1/data
# cd /var/www/html/
# rm -rf index.html reviewboard
# cp reviewboard1/conf/apache-wsgi.conf /etc/apache2/sites-available/
# cp reviewboard1/conf/apache-wsgi.conf /etc/apache2/sites-enabled/
# cd /etc/apache2/sites-enabled/
# rm -rf 000-default.conf
# cd sites-available/
# rm -rf 000-default.conf default-ssl.conf
# apt-get install libapache2-mod-wsgi

# service apache2 restart
# service apache2 status
# cp /var/www/html/reviewboard1/conf/apache-wsgi.conf reviewboard1.conf .
# cp /var/www/html/reviewboard1/conf/apache-wsgi.conf reviewboard1.conf
# rm -rf apache-wsgi.conf
# cd ../sites-enabled
# ln -s ../sites-available/reviewboard1.conf .

# vi /etc/apache2/sites-enabled/reviewboard1.conf
ServerName localhost

# service apache2 restart
# service apache2 status


Command Summary execute as it is installation of ReviewBoard will be done.

Saturday, 7 May 2016

reset rhel7 root password

In the RHCSA examination they ask to reset the root password, In this article we are going to learn how to reset rhel7 root user password.

Whenever you type user password incorrectly it will shown an above error. 


 Immediate After Right side of the corner there is a power button Click on that power button and Click on Restart Server. Server will restart.


 While restarting of server you have to press any key to stop the OS booting process yet the stage of Kernel. As shown in above screen shot kernel line will stop. Then Press 'e'

After pressing key 'e' then kernel lines will be edited. As shown in below screenshot
if you see there is a line start with "linux16" go to that line press 'END' key to go last of the line. In END of the line write "rd.break console=tty1" (without quotations). Then Press CTRL+x

Server will go to Single user mode. As shown in above screen shot.
In this mode /sysroot file system bill be mounted as ReadOnly. We have to make /sysroot as ReadWrite then only we can able to change the password.

Changing password means we are indirectly writing the encrypted password in /etc/shadow file.
To mount /sysroot file system in ReadWrite run below command
# mount -o remount,rw /sysroot

Now change to root using below command
#chroot /sysroot

Now prompt will be changed to Shell.
# passwd 
New Password: redhat
Retype Password: redhat

Now root password has been changed to 'redhat'. If you reboot the server will not come back. in RHEL7 by default SELinux is in enforced mode we have to relabel the SELinux inorder to bring back the server in Normal Stage.

To Relabel the SELinux run below command
# touch /.autorelabel

Now type exit exit two times System will be restart
 sh-4.2# exit
switch_root:/# exit

That's it now RHEL7 server will be back after that type username: root and Password: redhat.

Successfully rested RHEL7 root user password.

Thursday, 31 March 2016

DHCP Server RHEL7

DHCP Server :: Dynamic Host Control protocol

Port Number 67
Package: dhcp*
service : dhcpd.service
config file: /etc/dhcp/dhcpd.conf

[root@server7 ~]# yum install dhcp*
Loaded plugins: langpacks
Package 12:dhcp-common-4.2.5-27.el7.x86_64 already installed and latest version
Package 12:dhcp-libs-4.2.5-27.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-27.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                          Arch                               Version                                       Repository                            Size
==============================================================================================================================================================
Installing:
 dhcp                             x86_64                             12:4.2.5-27.el7                               rhel_dvd                             506 k

Transaction Summary
==============================================================================================================================================================
Install  1 Package

Total download size: 506 k
Installed size: 1.4 M
Is this ok [y/d/N]: y
Downloading packages:
dhcp-4.2.5-27.el7.x86_64.rpm                                                                                                           | 506 kB  00:00:00    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 12:dhcp-4.2.5-27.el7.x86_64                                                                                                                1/1
  Verifying  : 12:dhcp-4.2.5-27.el7.x86_64                                                                                                                1/1

Installed:
  dhcp.x86_64 12:4.2.5-27.el7                                                                                                                                

Complete!
[root@server7 ~]# systemctl enable dhcpd.service
ln -s '/usr/lib/systemd/system/dhcpd.service' '/etc/systemd/system/multi-user.target.wants/dhcpd.service'
[root@server7 ~]# systemctl start dhcpd.service
[root@server7 ~]# firewall-cmd --permanent --add-service=dhcp
success
[root@server7 ~]# firewall-cmd --reload
success
[root@server7 ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
[root@server7 ~]# vim /etc/dhcp/dhcpd.conf


## Default Line Number 48 ###
# A slightly different configuration for an internal subnet.
subnet 172.25.7.0 netmask 255.255.255.0 {
  range 172.25.7.20 172.25.7.22;
  option domain-name-servers ns1.internal.example.org;
  option domain-name "example.com";
  option routers 172.25.7.2;
  option broadcast-address 172.25.7.255;
  default-lease-time 600;
  max-lease-time 7200;
}


:wq! (Save & Exit)

#systemctl restart dhcpd.service

Tuesday, 22 March 2016

providing remote block storage - RHEL 7 / Centos 7

iSCSI, which stands for Internet Small Computer System Interface, works on top of the Transport Control Protocol (TCP) and allows the SCSI command to be sent end-to-end over local-area networks (LANs), wide-area networks (WANs) or the Internet.

  • Create one LVM
  • Convert that LVM into LUN using iSCSI Software
  • Map Converted LUN to initiator and use it as a local HDD to initiator

Creating LVM

[root@server4 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xab08db42.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): Hit Enter
Using default response p
Partition number (1-4, default 1):
Hit Enter 
First sector (2048-20971519, default 2048):Hit Enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +5G
Partition 1 of type Linux and of size 5 GiB is set

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@server4 ~]# partprobe /dev/vdb






[root@server4 ~]# pvcreate /dev/vdb1
  Physical volume "/dev/vdb1" successfully created
[root@server4 ~]# vgcreate vgiscsi /dev/vdb1
  Volume group "vgiscsi" successfully created
[root@server4 ~]# lvcreate -l 100%FREE -n lviscsi vgiscsi
  Logical volume "lviscsi" created


[root@server4 ~]# lvs
  LV      VG      Attr       LSize Pool Origin Data%  Move Log Cpy%Sync Convert
  lviscsi vgiscsi -wi-a----- 5.00g             


[root@server4 ~]# yum install targetcli*



[root@server4 ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> ls
o- / ......................................................................................................................... [...]
  o- backstores ........................................ [...]
  | o- block ........................... [Storage Objects: 0]
  | o- fileio ............................... [Storage Objects: 0]
  | o- pscsi ............................... [Storage Objects: 0]
  | o- ramdisk ............................ [Storage Objects: 0]
  o- iscsi ........................................ [Targets: 0]
  o- loopback ..................................... [Targets: 0]
/> /backstores/block create iscsilun /dev/vgiscsi/lviscsi
Created block storage object iscsilun using /dev/vgiscsi/lviscsi.
/> ls
o- / ...................................................... [...]
  o- backstores ........................................... [...]
  | o- block ............................... [Storage Objects: 1]
  | | o- iscsilun ...[/dev/vgiscsi/lviscsi (5.0GiB) write-thru deactivated]
  | o- fileio ................................. [Storage Objects: 0]
  | o- pscsi ............................... [Storage Objects: 0]
  | o- ramdisk ............................ [Storage Objects: 0]
  o- iscsi ........................................ [Targets: 0]
  o- loopback ..................................... [Targets: 0]
/> /iscsi create iqn.2017-03.com.arkit:server4
Created target iqn.2017-03.com.arkit:server4.
Created TPG 1.

/> ls
o- / ..................................................... [...]
  o- backstores .......................................... [...]
  | o- block .............................. [Storage Objects: 1]
  | | o- iscsilun .......... [/dev/vgiscsi/lviscsi (5.0GiB) write-thru deactivated]
  | o- fileio ............................. [Storage Objects: 0]
  | o- pscsi .............................. [Storage Objects: 0]
  | o- ramdisk ............................ [Storage Objects: 0]
  o- iscsi ........................................ [Targets: 1]
  | o- iqn.2017-03.com.arkit:server4 ................. [TPGs: 1]
  |   o- tpg1 ........................... [no-gen-acls, no-auth]
  |     o- acls ...................................... [ACLs: 0]
  |     o- luns ...................................... [LUNs: 0]
  |     o- portals ................................ [Portals: 0]
  o- loopback ...................................... [Targets: 0]


GO TO Client side and collect the iqn number

[root@desktop4 ~]# yum install iscsi*
Loaded plugins: langpacks
rhel_dvd                                                                                                                       | 4.1 kB  00:00:00    
(1/2): rhel_dvd/group_gz                                                                                                       | 134 kB  00:00:00    
(2/2): rhel_dvd/primary_db                                                                                                     | 3.4 MB  00:00:00    
Package iscsi-initiator-utils-6.2.0.873-21.el7.x86_64 already installed and latest version
Package iscsi-initiator-utils-iscsiuio-6.2.0.873-21.el7.x86_64 already installed and latest version
Nothing to do


[root@desktop4 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:9e96ff23da37
[root@desktop4 ~]# systemctl enable iscsid.service
ln -s '/usr/lib/systemd/system/iscsid.service' '/etc/systemd/system/multi-user.target.wants/iscsid.service'
[root@desktop4 ~]# systemctl start iscsid.service



Come Back to the Server and Map LUN to Initiator


/> /iscsi/iqn.2017-03.com.arkit:server4/tpg1/acls create iqn.1994-05.com.redhat:9e96ff23da37
Created Node ACL for iqn.1994-05.com.redhat:9e96ff23da37
/> iscsi/iqn.2017-03.com.arkit:server4/tpg1/luns create /backstores/block/iscsilun
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.1994-05.com.redhat:9e96ff23da37

/> /iscsi/iqn.2017-03.com.arkit:server4/tpg1/portals create 172.25.4.11
Using default IP port 3260
Created network portal 172.25.4.11:3260.

/> saveconfig
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json


Press CTRL + D

[root@server4 ~]# firewall-cmd --permanent --add-port=3260/tcp
success
[root@server4 ~]# firewall-cmd --reload
success


Go To Client and Connect the Mapped LUN

[root@desktop4 ~]# iscsiadm -m discovery -t st -p 172.25.4.11
172.25.4.11:3260,1 iqn.2017-03.com.arkit:server4
[root@desktop4 ~]# iscsiadm -m node -T iqn.2017-03.com.arkit:server4 -p 172.25.4.11 -l
Logging in to [iface: default, target: iqn.2017-03.com.arkit:server4, portal: 172.25.4.11,3260] (multiple)
Login to [iface: default, target: iqn.2017-03.com.arkit:server4, portal: 172.25.4.11,3260] successful.


[root@desktop4 ~]# fdisk -l /dev/sda

Disk /dev/sda: 5364 MB, 5364514816 bytes, 10477568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes


[root@desktop4 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x2e115ccc.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (8192-10477567, default 8192):
Using default value 8192
Last sector, +sectors or +size{K,M,G} (8192-10477567, default 10477567):
Using default value 10477567
Partition 1 of type Linux and of size 5 GiB is set

Command (m for help): p

Disk /dev/sda: 5364 MB, 5364514816 bytes, 10477568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
Disk label type: dos
Disk identifier: 0x2e115ccc

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            8192    10477567     5234688   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@desktop4 ~]# partprobe /dev/sda
[root@desktop4 ~]# mkfs.ext4 /dev/sda1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
327680 inodes, 1308672 blocks
65433 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1340080128
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

[root@desktop4 ~]# mkdir /ravi



[root@desktop4 ~]# vim /etc/fstab
[root@desktop4 ~]# cat /etc/fstab |grep sda
/dev/sda1    /ravi    ext4    _netdev    0 0
[root@desktop4 ~]# mount -a
[root@desktop4 ~]# df -h |grep ravi
/dev/sda1       4.8G   20M  4.6G   1% /ravi


Enjoy................

Monday, 14 March 2016

Searching file content in Linux/Unix

1. Check Grep version
grep -V

2. Search single word in single file / multifles
grep <string> *

3. Search Multiple words in single file / multiple files
grep -E 'word1|word2'

4. Seach text which is not maching to string
grep -v "String" fileName

5. Print the matching string and its before lines
grep ens33 -A 4

6. Print the matching string and its after lines and its around lines
grep enss33 -B 4
grep ens33 -C 4


7. Search a string Recursively
grep -r <string> <fileName>

8. Grep the string with highlighted in color
grep --color=auto <string> <file Name>
export GREP_COLOR='1;30;43'


9. display the lines which does not matches all the given strings
grep -v -e "a" -e "b" -e "c" filename.txt

10. Get the count of given string from file
grep -c <string> filename

11. Search for files which are matching to the given string
grep -l this demo*

12. Beginning of line (^) using cap symble
grep "^Nov 10" messages.1

13. End of the line ( $) using dollar symble
grep "terminating.$" messages



? The preceding item is optional and matched at most once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{n} The preceding item is matched exactly n times.
{n,} The preceding item is matched n or more times.
{,m} The preceding item is matched at most m times.
{n,m} The preceding item is matched at least n times, but not more than m times.

Few examples about grep command..

Comment one grep command below in comment section....

Sunday, 13 March 2016

Managing Files and Directories - Linux


                In Linux all are files only. Based on the type we identify the files. In this article we are going to see how to create, list, copy, move and delete the files and directories. 

1. Creating files and Directories
2. Listing Files and Directories
3. Copying Files and Directories
4. Moving files and directories
5. Deleting Files and Directories


Create empty files 

To create an empty files, we have to use touch command

                           touch is a standard Unix command-line interface program which is used to update the access date and / or modification date of a file or directory. In its default usage, it is the equivalent of creating or opening a file and saving it without any change to the file contents. Touch eliminates the unnecessary steps of opening the file, saving the file, and closing the file again. Instead it simply updates the dates associated with the file or directory. An updated access or modification date can be important for a variety of other programs such as backup utilities or the make command-line interface programming utility. Typically these types of programs are only concerned with files which have been created or modified after the program was last run.
[root@server1 touch]# touch file
[root@server1 touch]# ls -l
total 0
-rw-r--r--. 1 root root 0 Mar 13 07:01 file

[root@server1 touch]# touch file1 file2 file3 file4
[root@server1 touch]# ls -l
total 0
-rw-r--r--. 1 root root 0 Mar 13 07:08 file1
-rw-r--r--. 1 root root 0 Mar 13 07:08 file2
-rw-r--r--. 1 root root 0 Mar 13 07:08 file3
-rw-r--r--. 1 root root 0 Mar 13 07:08 file4

[root@server1 touch]# touch ravi{1..10}.txt
[root@server1 touch]# ls -l
total 0
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi10.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi1.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi2.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi3.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi4.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi5.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi6.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi7.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi8.txt
-rw-r--r--. 1 root root 0 Mar 13 07:09 ravi9.txt

Create file using cat command

                          The program cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to catenate/concatenate and list files.

[root@server1 cat]# cat > filebycat
This file is created by cat command
[root@server1 cat]# cat filebycat
This file is created by cat command

Creating Directories

mkdir (make directory) command in the Unix, DOS and OS/2 and MS windows and other programs is used to make a new directory.

[root@server1 mkdir]# mkdir testdir
[root@server1 mkdir]# mkdir dirtest dir1
[root@server1 mkdir]# ls -l
total 0
drwxr-xr-x. 2 root root 6 Mar 13 07:16 dir1
drwxr-xr-x. 2 root root 6 Mar 13 07:16 dirtest
drwxr-xr-x. 2 root root 6 Mar 13 07:16 testdir


Listing files and directories

                        To list the files and directories we have to use 'ls' command. 'ls' command will list files and directories current directory, by providing the remote directory path will list all files and directories on that remote directory.

ls command with 25 practical examples

ls <Path>

[root@server1 mkdir]# ls
dir1  dirtest  testdir
[root@server1 mkdir]# ls -ltr
total 0
drwxr-xr-x. 2 root root 6 Mar 13 07:16 testdir
drwxr-xr-x. 2 root root 6 Mar 13 07:16 dirtest
drwxr-xr-x. 2 root root 6 Mar 13 07:16 dir1
[root@server1 mkdir]# ls -k
dir1  dirtest  testdir


Copy files and directories

                         cp is a UNIX command for copying files and directories. The command has three principal modes of operation, expressed by the types of arguments presented to the program for copying a file to another file, one or more files to a directory, or for copying entire directories to another directory.

we have to use -r option along with cp command to copy the directories.

cp <SourcePath> <DestinationPath>

[root@server1 ~]# cp file1 dir1/
[root@server1 ~]# cp testdir dir1/
cp: omitting directory ‘testdir’
[root@server1 ~]# cp -r testdir dir1/

Moving files and directories

                   mv (short for move) is a Unix command that moves one or more files or directories from one place to another. If both filenames are on the same filesystem, this results in a simple file rename; otherwise the file content is copied to the new location and the old file is removed. Using mv requires the user to have write permission for the directories the file will move between. This is because mv changes the content of both directories (i.e., the source and the target) involved in the move. When using the mv command on files located on the same filesystem, the file's timestamp is not updated.

mv <SourcePath> <DestinatioPath>

[root@server1 ~]# mv file3.txt /tmp/
mv: overwrite ‘/tmp/file3.txt’? y

[root@server1 ~]# mv dir1/ /tmp/
mv: overwrite ‘/tmp/dir1’? y
mv: cannot move ‘dir1/’ to ‘/tmp/dir1’: File exists


Deleting Files and Directories

               rm (short for remove) is a basic UNIX command used to remove objects such as files, directories, device nodes, symbolic links, and so on from the filesystem. To be more precise, rm removes references to objects from the filesystem, where those objects might have had multiple references (for example, a file with two different names), and the objects themselves are discarded only when all references have been removed and no programs still have open handles to the objects.

[root@server1 ~]# ls
anaconda-ks.cfg  file1       file5.txt  file8.txt             mkdir  tech1  testdir   touch
cat              file10.txt  file6.txt  file9.txt             pipe   tech2  testdir1
dir1             file4.txt   file7.txt  initial-setup-ks.cfg  Pipe   tech3  testdir2

[root@server1 ~]# rm -rf file*

[root@server1 ~]# ls
anaconda-ks.cfg  dir1                  mkdir  Pipe   tech2  testdir   testdir2
cat              initial-setup-ks.cfg  pipe   tech1  tech3  testdir1  touch


We have a different file types in Linux we will discuss about few file types:


1. Regular Files (-)

we can create files using #touch command

[root@server1 ~]# ls -l |grep ^-
-rw-------. 1 root root 1292 Jan 19 23:14 anaconda-ks.cfg
-rw-r--r--. 1 root root 1343 Jan 19 23:15 initial-setup-ks.cfg
-rw-r--r--. 1 root root   31 Mar 13 04:54 Pipe


2. Directory Files (d)

Directories will start with d character we can search the directories using below command

[root@server1 ~]# ls -l /* |grep ^d
drwxr-xr-x. 2 root root       26 Jan 19 23:08 grub
drwxr-xr-x. 6 root root      104 Jan 19 23:14 grub2
drwxr-xr-x. 2 root root         200 Mar 13 01:16 block


3. Block File (b)

These files are hardware files most of them are present in /dev
find block file in Linux

ls -l /dev/* |grep ^b

[root@server1 ~]# ls -l /dev/* |grep ^b
brw-rw----. 1 root disk      8,   0 Mar 13 01:16 /dev/sda
brw-rw----. 1 root disk      8,   1 Mar 13 01:16 /dev/sda1
brw-rw----. 1 root disk      8,   2 Mar 13 01:16 /dev/sda2
brw-rw----. 1 root disk      8,  16 Mar 13 01:16 /dev/sdb
brw-rw----. 1 root cdrom    11,   0 Mar 13 01:16 /dev/sr0


4. Character device file (c)

Provides a serial stream of input or output.Your terminals are classic example for this type of files.

[root@server1 ~]# ls -l /dev/* |grep ^c
crw-rw-rw-. 1 root tty       5,   0 Mar 13 01:16 /dev/tty
crw--w----. 1 root tty       4,   0 Mar 13 01:16 /dev/tty0
crw--w----. 1 root tty       4,   1 Mar 13 01:18 /dev/tty1
crw--w----. 1 root tty       4,  10 Mar 13 01:16 /dev/tty10


5. Named Pipe file Or Just a pipe file (p)

The other name of pipe is a “named” pipe, which is sometimes called a FIFO. FIFO stands for “First In, First Out” and refers to the property that the order of bytes going in is the same coming out. The “name” of a named pipe is actually a file name within the file system.

Create pipe file using below command
# mkfifo pipe

[root@server1 ~]# ls -l |grep ^p
prw-r--r--. 1 root root    0 Mar 13 04:52 pipe


6. symbolic link file (l)

These are linked files to other files. They are either Directory/Regular File. The inode number for this file and its parent files are same. There are two types of link files available in Linux/Unix ie soft and hard link. 

#ls -l |grep ^l

7. Socket file (s)

A socket file is used to pass information between applications for communication purpose 

#ls -l |grep ^s


How did you feel about this article....?



Friday, 11 March 2016

Red Hat Enterprise Linux 7 - RHCSA and RHCE Complete Course content in detailed

I would like to share an RHCSA & RHCE examination course content in detailed.

This is an Red Hat Enterprise Linux 7 course offered by the Red Hat organization, it is not an objective exam, it is an practical exam which we have to do it practically in exam centre.

Red Hat Enterprise Linux Administrator Course which will cover RH124 and RH134 books. In New version we say EX200.

RHCSA Exam will be 3.5 Hours and total marks for the exam is 300. Out of 300, pass marks are 210.

Red Hat Certified Engineer Exam is also practical exam and the duration is 3.5 Hours. Total marks 300. Pass marks are 210.

Below is the complete RHCSA & RHCE course content in detailed.


S.No Course Topic Description
1 RHCSA Introduction to course outline and certification
2 RHCSA Linux Architecture
3 RHCSA Linux Vs Windows
4 RHCSA Linux Directory Structure
5 RHCSA Installing VMWare work Station
6 RHCSA Configuring virtual Network communication
7 RHCSA Installing Linux Operating system using Installation media (DVD)
8 RHCSA Installing and configuring Lab Main Server / DNS / LDAP / Kerberos, Certificate Authority and 389 Directory Server
9 RHCSA Bash shell features
10 RHCSA Managing files & directories
11 RHCSA Basic Commands ls, cp, mkdir, cat, rm and rmdir
12 RHCSA Getting help from using command line (whatis, whereis, man, help, info, --help and pinfo)
13 RHCSA Editing Viewing of text files using nano
14 RHCSA Linux Directory Structure
15 RHCSA Using visual editor & visual editor modified to edit files
16 RHCSA User Administration Creating, Modifying and Deleting
17 RHCSA Cotrolling services & daemons
18 RHCSA IPv4 Networking
19 RHCSA Installing and configuring SSH Server & Client
20 RHCSA Listing and managing processes
21 RHCSA Prioritize process
22 RHCSA Analyze & storing logs
23 RHCSA Syslog Server & Client configuration
24 RHCSA Compressing files & directories (tar and zip)
25 RHCSA Copying files & directories to remote servers
26 RHCSA Red Hat Package Manager
27 RHCSA Installing and configuring Local Yellodog Updater, Modified
28 RHCSA Installing and configuring FTP / HTTP Yellowdog Updater, Modified
29 RHCSA Managing network interfaces using nmcli utility
30 RHCSA Searching files and directories
31 RHCSA File & Directory links (Soft Links and Hard Links)
32 RHCSA Managing of physical storage - Creating Standard Partitions
33 RHCSA Creating and Managing Logical Volume Manager
34 RHCSA XFS quota management
35 RHCSA Access Control List (ACL)
36 RHCSA Scheduling of future Linux tasks using at & Crontab
37 RHCSA SeLinux Overview
38 RHCSA SeLinux Policy types, Listing policies and applying policies
39 RHCSA NFS Server and Client configuration
40 RHCSA Firewalld - configuring and managing rules
41 RHCSA Securing the NFS using kerberos
42 RHCSA Adding server as LDAP client
43 RHCSA Setting up ldap users home directory
44 RHCSA Accessing the network storage using (CIFS) samba
45 RHCSA Samba Multiuser Access
46 RHCSA Using Virtualized systems
47 RHCSA Creating virtual Machines
48 RHCSA Automated installation of Redhat Linux
49 RHCSA Automated Installation using Kickstart
50 RHCSA Explaining Linux booting process
51 RHCSA Recoverying forgotten root password
52 RHCSA Recoverying forgotten root password method-2
53 RHCSA Fixing Partition Errors - using emergency mode
54 RHCSA Managing daemons and serviecs
55 RHCSA MariaDB Installation and Configuration
56 RHCSA Using regular expressions with grep
57 RHCE Installation & configuration of DHCP Server - reserving IP address
58 RHCE DNS master server zones installation & configuration
59 RHCE Installing and Configuring the Web / Httpd/ Apache Server
60 RHCE Configuring virtual web server
61 RHCE Making secure web server (https) ssl enabled web server
62 RHCE WSGI script enabled web server
63 RHCE Networking IPv6 assinging IPv6 Address
64 RHCE Time synchronizing using NTP server and client
65 RHCE Configure a system to forward all email to a central mail server
66 RHCE Install and configure MariaDB
67 RHCE Backup and restore a database
68 RHCE Create a simple database schema
69 RHCE Perform simple SQL queries against a database
70 RHCE Configure a system as either an iSCSI target or initiator that persistently mounts an iSCSI target
71 RHCE Use network teaming or bonding to configure aggregated network links between two Red Hat Enterprise Linux systems
72 RHCSA Red Hat Certified Administrator Exam Practice Paper
73 RHCSA Red Hat Certified Administrator Exam Practice Paper - 1
74 RHCE Red Hat Certified Engineer Exam Practice Paper
75 RHCE Red Hat Certified Engineer Exam Practice Paper - 1


Please comment your valuable feedback.