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.

Saturday 30 January 2016

20 useful tar and zip commands


Introduction to File compression and archiving

20 useful tar and zip commands  It is useful to store a group of files in one file for easy backup, for transfer to another directory, or for transfer to another computer. It is also useful to compress large files; compressed files take up less disk space and download faster via the Internet.

It is important to understand the distinction between an archive file and a compressed file. An archive file is a collection of files and directories stored in one file. The archive file is not compressed — it uses the same amount of disk space as all the individual files and directories combined. A compressed file is a collection of files and directories that are stored in one file and stored in a way that uses less disk space than all the individual files and directories combined. If disk space is a concern, compress rarely-used files, or place all such files in a single archive file and compress it.

Note: tar file is not a compressed file, but compressed file is archived file

As we so many extensions to compress the files using tar command, as we take few examples in this article. All the extensions will work to compress the files and directories but there compression ratio is different compare to each other. Based extension compression ratio we can use different options.

1. gzip

2. bzip

3. zip

Syntax: tar <File Name.tar> <directory / file path>

1. Archiving files using tar command

Archiving is not an compression of files and directories it's an kind of group all the files and directories together in single file, instead of multiple files. After creating an archive file, we can't see size difference in between actual file system size and archive file.

Let's see an example below

[root@TechTutorial tar]# du -h *.txt   <<-- Files Size before creating an archive  44K     d.txt  44K     g.txt  44K     kumar.txt  44K     ravi.txt  44K     tech.txt  44K     test1.txt  44K     test2.txt  44K     test3.txt  44K     test4.txt  [root@TechTutorial tar]# tar -cvf ravi.tar *.txt   << to Create an Archive file command  d.txt  g.txt  kumar.txt  ravi.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt  [root@TechTutorial tar]# du -h ravi.tar  << -- After Creating an archive file size  380K    ravi.tar

explanation of tar command options

-c Create an archive file

-v verbose (display all files status to archive)

-f specifying the files

2. Extracting an archive file

In order to extract the archive file we have to use -x option along with tar command

[root@TechTutorial tar]# tar -xvf ravi.tar  d.txt  g.txt  kumar.txt  ravi.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt

3. Updating an archive file with newly created files

There is a requirement that, we have to update an archive file by adding only newly created files.  Adding only newly created files to archive will save us the lot of time.

Let's see an example as shown below, when we use -u option along with tar command it will update the tar file with newly created files

[root@TechTutorial tar]# touch Techtutorials.txt  [root@TechTutorial tar]# tar -uvf ravi.tar *.txt  Techtutorials.txt

4. List files from archive without extracting them

all the times we know need to extract an archive in order to see the archive content, if it is an large file its very difficult to extract and it takes lot of time to extract and required disk space as well to extract the files.

We have to use '-t' option to see all files which are there in archive file

[root@TechTutorial tar]# tar -tf ravi.tar  d.txt  g.txt  kumar.txt  ravi.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt  Techtutorials.txt

5. Extract single file from archive

This option is very handy whenever we have an large archive file, we need only single file from that archive to be restored. In order to restore an single file from archive we have to use wildcards

[root@TechTutorial tar]# rm -rf *.txt  <<-- Deleted all the Files from current location  [root@TechTutorial tar]# ls   << -- After Deletion we have below files  3  arkit10.doc  arkit1.doc  arkit2.doc  arkit3.doc  arkit5.doc  arkit6.doc  arkit7.doc  arkit8.doc  arkit9.doc  ravi.tar  [root@TechTutorial tar]# tar -xvf ravi.tar Techtutorials.txt   <<<-- Restored an single file from archive  Techtutorials.txt  [root@TechTutorial tar]# ls   <<-- After Restoration we have below files  3            arkit1.doc  arkit3.doc  arkit6.doc  arkit8.doc  ravi.tar  arkit10.doc  arkit2.doc  arkit5.doc  arkit7.doc  arkit9.doc  Techtutorials.txt

above is the example how we can restore a single from archive

6. Extract multiple files from archive (not all files)

As you see in 5th step we extracted single file from archive, in the same way we are going to extract an multiple files from archive (not all).

Note: in order to extract files from archive you have to know exact file names, you can use '-t' to see all the files in archive

[root@TechTutorial tar]# rm -rf Techtutorials.txt   <<-- To get clarity deleted previous presented files  [root@TechTutorial tar]# tar -xvf ravi.tar "Techtutorials.txt" "test1.txt"  test1.txt  Techtutorials.txt  [root@TechTutorial tar]# ls  3            arkit1.doc  arkit3.doc  arkit6.doc  arkit8.doc  ravi.tar           test1.txt  arkit10.doc  arkit2.doc  arkit5.doc  arkit7.doc  arkit9.doc  Techtutorials.txt  [root@TechTutorial tar]# rm -rf Techtutorials.txt test1.txt  [root@TechTutorial tar]# tar -xvf ravi.tar --wildcards *.txt  d.txt  g.txt  kumar.txt  ravi.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt  Techtutorials.txt    

Note:: As we deleting the previous files only for demonstration only, DO NOT DELETE FILES in your environment.

you can mention multiple file names and also we can use wildcard option to restore multiple files as shown above example

7. Compressing files in gzip

As of now we see how to archive an files (grouping files together in single file). After creating an archive we did not get an space saving benefit because archive will not compress an files, file size will not decrease. When we compress an files we save disk space. If we want to create 'gzip' file with extension '.gz' we have to use '-z' option along with 'tar' command.

Let's see an example

[root@TechTutorial tar]# tar -czvf tech.tar.gz *.txt  d.txt  g.txt  kumar.txt  ravi.txt  Techtutorials.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt  [root@TechTutorial tar]# ls  3            arkit2.doc  arkit6.doc  arkit9.doc  kumar.txt  tech.tar.gz        test1.txt  test4.txt  arkit10.doc  arkit3.doc  arkit7.doc  d.txt       ravi.tar   Techtutorials.txt  test2.txt  arkit1.doc   arkit5.doc  arkit8.doc  g.txt       ravi.txt   tech.txt           test3.txt  [root@TechTutorial tar]# du -h tech.tar.gz  4.0K    tech.tar.gz  [root@TechTutorial tar]# du -h *.txt  44K     d.txt  44K     g.txt  44K     kumar.txt  44K     ravi.txt  0       Techtutorials.txt  44K     tech.txt  44K     test1.txt  44K     test2.txt  44K     test3.txt  44K     test4.txt  [root@TechTutorial tar]#

As shown in above example, after compression of text files using '-z' we got an compression file size is 4KB actual file size 380KB

8. Compressing files using bzip

Its also same like 'gzip' only but compression ratio of '.bz2′ is more compare to '.gz' we are going to compress same files as we used in above example and see how much we will get the compressed file size, for 'bzip' we have to use '-j' option.

[root@TechTutorial tar]# tar -cjvf 1tech.tar.bz2 *.txt  d.txt  g.txt  kumar.txt  ravi.txt  Techtutorials.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt  [root@TechTutorial tar]# du -h 1tech.tar.bz2  4.0K    1tech.tar.bz2

In this comparison of '.gz' and '.bz2' compression methods practical examples are below

9. Compression ratio of .gz (gzip) and .bz2 (bzip)

After compressing 34MB using '.gz' output file size is 8.6MB.

Using same  files compressed with '.bz2' output file size is 7.2MB. Comparatively .bz2 compression ratio is higher than .gz

[root@TechTutorial tar]# du -h tarr.tar.gz  8.6M    tarr.tar.gz  [root@TechTutorial tar]# du -h tarr.tar.bz2  7.2M    tarr.tar.bz2

10. Extracting compressed files from 'gzip' and 'bzip'

To extract 'gzip' and 'bzip' files we have to use '-x' option along with there own options '-z' for gzip and '-j' for bzip.

Below is the example for extracting the 'bzip' file

[root@TechTutorial tar]# tar -xjvf 1tech.tar.bz2  d.txt  g.txt  kumar.txt  ravi.txt  Techtutorials.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt

Below is the practical example for extracting the 'gzip' file

[root@TechTutorial tar]# tar -xzvf tech.tar.gz  d.txt  g.txt  kumar.txt  ravi.txt  Techtutorials.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt  [root@TechTutorial tar]#

11. zipping the files using zip command

zip command is used to compress the files with .zip extension, zip is available in different platform's such as Unix, Linux, Windows and MAC.

Syntax:  zip <Destination File Path and Name>.zip  <source files to compress>

below is the example to compress the files using 'zip' command

[root@TechTutorial tar]# zip docfiles.zip *.txt    adding: d.txt (deflated 100%)    adding: g.txt (deflated 100%)    adding: kumar.txt (deflated 100%)    adding: ravi.txt (deflated 100%)    adding: Techtutorials.txt (stored 0%)    adding: tech.txt (deflated 100%)    adding: test1.txt (deflated 100%)    adding: test2.txt (deflated 100%)    adding: test3.txt (deflated 100%)    adding: test4.txt (deflated 100%)  [root@TechTutorial tar]#

12. zipping files and directories along with sub directories and its files

When we use remote directory compression using 'zip' command it will not compress all the sub directories and its content in order to compress all the sub directories and its files we have to use '-r' along with zip command

[root@TechTutorial tar]# zip -r subdir.zip ravi/    adding: ravi/ (stored 0%)    adding: ravi/kumar/ (stored 0%)    adding: ravi/kumar/tech/ (stored 0%)    adding: ravi/kumar/tech/d.txt (deflated 100%)    adding: ravi/kumar/tech/g.txt (deflated 100%)    adding: ravi/kumar/tech/kumar.txt (deflated 100%)    adding: ravi/kumar/tech/ravi.txt (deflated 100%)

13. compressing with high compression ratio

zip command has good feature that we can also mention an compression ratio option from 1 to 9. 9 gives high compression.

[root@TechTutorial tar]# zip -9 -r deepcompress.zip ravi/    adding: ravi/ (stored 0%)    adding: ravi/kumar/ (stored 0%)    adding: ravi/kumar/tech/ (stored 0%)    adding: ravi/kumar/tech/d.txt (deflated 100%)    adding: ravi/kumar/tech/g.txt (deflated 100%)    adding: ravi/kumar/tech/kumar.txt (deflated 100%)    adding: ravi/kumar/tech/ravi.txt (deflated 100%)    adding: ravi/kumar/tech/Techtutorials.txt (stored 0%)    adding: ravi/kumar/tech/tech.txt (deflated 100%)    adding: ravi/kumar/tech/test1.txt (deflated 100%)    adding: ravi/kumar/tech/test2.txt (deflated 100%)    adding: ravi/kumar/tech/test3.txt (deflated 100%)    adding: ravi/kumar/tech/test4.txt (deflated 100%)

14. Excluding particular file / directory from compression

We can also exclude file from compression in order to do that '-x' we have to use.

[root@TechTutorial tar]# zip -r compress1.zip ravi/ -x ravi/g.txt    adding: ravi/ (stored 0%)    adding: ravi/d.txt (deflated 100%)    adding: ravi/kumar.txt (deflated 100%)    adding: ravi/ravi.txt (deflated 100%)    adding: ravi/Techtutorials.txt (stored 0%)    adding: ravi/tech.txt (deflated 100%)    adding: ravi/test1.txt (deflated 100%)    adding: ravi/test2.txt (deflated 100%)    adding: ravi/test3.txt (deflated 100%)    adding: ravi/test4.txt (deflated 100%)  [root@TechTutorial tar]# ls ravi/  d.txt  g.txt  kumar.txt  ravi.txt  Techtutorials.txt  tech.txt  test1.txt  test2.txt  test3.txt  test4.txt

15. Delete particular file from zip

We can also delete an file from compressed file using option '-d' along with zip command

[root@TechTutorial tar]# zip -d compress1.zip ravi/tech.txt  deleting: ravi/tech.txt

16. Update newly created files to zip

We can update zip file using '-u' option which will only add newly created files to zip file.

[root@TechTutorial tar]# touch Update2.txt  [root@TechTutorial tar]# zip -u compress1.zip *.txt    adding: Update2.txt (stored 0%)  [root@TechTutorial tar]#

17. Update zip with newly modified files

Update only modifed files to zip file, in order to do modified file update use '-fr' option

[root@TechTutorial tar]# zip -fr compress1.zip *.txt  freshening: Update2.txt (stored 0%)  [root@TechTutorial tar]#

18. List all files from zip without extracting them

List all files from zip without extracting them

# less compress.zip

19. Check zip file content without extracting

Without extracting zip file, if you want to see zipped file content you can see using 'zmore' and 'zless' commands.

# zmore compress.zip  # zless comress.zip

20. De-compress zip file

In order to extract the zip file we have to use 'unzip' command. If files are exists it will ask you for the confirmation to re-write the same.

[root@TechTutorial tar]# unzip compress1.zip  Archive:  compress1.zip  replace d.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y    inflating: d.txt  replace g.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y    inflating: g.txt  replace kumar.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: A    inflating: kumar.txt

20 useful tar and zip commands 20 useful tar and zip commands 20 useful tar and zip commands 20 useful tar and zip commands 20 useful tar and zip commands

:: Conclusion ::

We can group all files and directories in a single file by archiving, We can also compress the files and directories in order to save the disk space. Archiving files and directories will not save a disk space.

Thanks for your precious time, please write your comments below ….