Monday, 27 January 2014

Intruducation of Linux


                                                        Introducation of Linux 

What is Linux ?
Linux is a free open-source operating system based on Unix. Linus Torvalds originally created Linux with the assistance of developers from around the world. Linux is:

-> Free
-> Unix like
-> Open Source
-> Network operating System
-> Stable
-> Robust
-> Secure
-> High performance

It is excellent operating system for:-

-> Desktop computer
-> Web server
-> Software development workstation
-> Network monitoring workstation
-> Workgroup server
-> Killer network services such as DHCP, Firewall, Router, FTP, SSH, Mail, Proxy, Proxy Cache server etc.

                                                        History of Linux

In 1991, Linus Torvalds was studying UNIX at university, where he was using a special educational experimental purpose operating system called Minix (a small version of UNIX to be used in the academic environment). However, Minix had its limitations and Linus felt he could create something better. Therefore he developed his own version of Minix, known as Linux. Linux was Open Source right from the start. Linux is a kernel developed by Linus. The kernel was bundled with system utilities and libraries from the GNU project to create a usable operating system. Sometimes people refer to Linux as GNU/Linux because it has system utilities and libraries from the GNU project. Linus Torvalds is credited for creating the Linux Kernel, not the entire Linux operating system[1].

Linux distribution = Linux kernel + GNU system utilities and libraries + Installation scripts + Management utilities etc.

What is kernel ?

The kernel is the heart of the Linux operating system. Linux is not operating system. Linux is a kernel. A kernel provides access to the computer hardware and control access to resources such as:

-> File management.
-> Multitasking.
-> Memory management.
-> I/O management.
-> Process management.
-> device management.
-> Running programs.
-> Loading programs into memory.
-> Networks.
-> Security and firewall.
-> Other resources etc.

The kernel decides who will use these resources and for how long and when. It runs your programs or sets up to execute binary files. The kernel acts as an intermediary between the computer hardware and various applications.

What is Shell ?

Computers understand the language of zeros and ones known as binary language. In the early days of computing, instructions were provided using binary language, which is difficult for all of us to read and write. Therefore, in an operating system there is a special program called the shell. The shell accepts human readable commands and translates them into something the kernel can read and process.

In short : 

-> It is a command language interpreter that executes commands read from the standard input device such as keyboard or from a file.
-> The shell is not part of system kernel, but uses the system kernel to execute programs, create files etc.

Several shells are available for Linux including:

BASH ( Bourne-Again SHell ) - Most common shell in Linux. It's Open Source.
CSH (C SHell) - The C shell's syntax and usage are very similar to the C programming language.
KSH (Korn SHell) - Created by David Korn at AT & T Bell Labs. The Korn Shell also was the base for the POSIX Shell standard specifications.
TCSH - It is an enhanced but completely compatible version of the Berkeley UNIX C shell (CSH).

Please note that each shell does the same job, but each understands different command syntax and provides different built-in functions. Under MS-DOS, the shell name is COMMAND.COM which is also used for the same purpose, but it is by far not as powerful as our Linux Shells are!

How do I find out my current shell name?

To find all of the available shells in your system, type the following command:

root@bhandari]# cat /etc/shells

In case the /etc/shells file has more than one shell listed under it, then it means that more than one shell is supported by your platform.

Command Line Interface (CLI)

The shell provides an interface to Linux where you can type or enter commands using the keyboard. It is known as the command line interface (CLI).

To find out your current shell type following command.

root@bhandari]# echo $SHELL
root@bhandari]# ps $$
root@bhandari]# ps -p $$

The following sample output indicate that I am using bash shell:

 PID TTY          TIME CMD
13931 pts/4    00:00:00 bash

Basic Command Line Editing

You can use the following key combinations to edit and recall commands:

CTRL + L : Clear the screen.
CTRL + W : Delete the word starting at cursor.
CTRL + U : Clear the line i.e. Delete all words from command line.
Up and Down arrow keys : Recall commands (see command history).
Tab : Auto-complete files, directory, command names and much more.
CTRL + R : Search through previously used commands (see command history)
CTRL + C : Cancel currently running commands.
CTRL + T : Swap the last two characters before the cursor.
ESC + T : Swap the last two words before the cursor.
CTRL + H : Delete the letter starting at cursor.

Getting Help In Linux

Most commands under Linux will come with documentation.

You can view documentation with the man command or info command. In this example, open the manpage for date command:

root@bhandari]# man date

You can read info documentation as follows for the ls command:

root@bhadnari]# info ls

Many commands accepts --help or -h command line option. In this example, display help options for the date command:

root@bhandari]# date --help

In short use any one of the following option to get more information about Linux commands:

man commandName
info commandName
commandName -h
commandName --help

Wednesday, 8 January 2014

How to configure DNS in Rhel6.4


========How to configure DNS in Rhel6.4=============


[root@master ~]# yum install bind*

[root@master ~]# cp -p /etc/named.* /var/named/chroot/etc/

[root@master ~]# rm -rf /etc/named.*

[root@master ~]# cp -p /var/named/named.* /var/named/chroot/var/named/

[root@master ~]# rm -rf /var/named/named.*

[root@master ~]# cd /var/named/chroot/etc/

[root@master etc]# ll
total 28
-rw-r--r-- 1 root root   265 Jan  8 21:35 localtime
drwxr-x--- 2 root named 4096 Dec  5  2012 named
-rw-r----- 1 root named 1008 Jul 19  2010 named.conf
-rw-r--r-- 1 root named 2389 Dec  5  2012 named.iscdlv.key
-rw-r----- 1 root named  931 Jun 21  2007 named.rfc1912.zones
-rw-r--r-- 1 root named  487 Jul 19  2010 named.root.key
drwxr-x--- 3 root named 4096 Jan  8 21:35 pki


[root@master etc]# cat named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
listen-on port 53 { 127.0.0.1;192.168.122.132; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query     { localhost; };
recursion yes;

dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;

/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
type hint;
file "named.ca";
};

zone "example.com" IN {
        type master;
        file "tom";
        allow-update { none; };
};

zone "122.168.192.in-addr.arpa" IN {
        type master;
        file "jerry";
        allow-update { none; };
};


[root@master ~]# cd /var/named/chroot/var/named/

[root@master named]# cp -p named.localhost tom

[root@master named]# cat tom
$TTL 1D
@ IN SOA master.example.com. root.master.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master.example.com.
master A 192.168.122.132

[root@master named]# cp -p named.empty jerry

[root@master named]# cat jerry
$TTL 3H
@ IN SOA master.example.com. root.master.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master.example.com.
132     PTR     master.

[root@master named]# /etc/init.d/named start
Generating /etc/rndc.key:                                  [  OK  ]
Starting named:                                            [  OK  ]


[root@master ~]# nslookup master.example.com   (FQDN)
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: master.example.com
Address: 192.168.122.132


[root@master ~]# dig master.example.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> master.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23023
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;master.example.com. IN A

;; ANSWER SECTION:
master.example.com. 86400 IN A 192.168.122.132

;; AUTHORITY SECTION:
example.com. 86400 IN NS master.example.com.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Jan  8 21:52:46 2014
;; MSG SIZE  rcvd: 66


[root@master ~]# dig -x 192.168.122.132

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> -x 192.168.122.132
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35520
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;132.122.168.192.in-addr.arpa. IN PTR

;; ANSWER SECTION:
132.122.168.192.in-addr.arpa. 10800 IN PTR master.

;; AUTHORITY SECTION:
122.168.192.in-addr.arpa. 10800 IN NS master.example.com.

;; ADDITIONAL SECTION:
master.example.com. 86400 IN A 192.168.122.132

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Jan  8 21:53:02 2014
;; MSG SIZE  rcvd: 114