How to Configure Static IP Address on CentOS 5.8 x86

In this post, i will share the quick steps on how to configure static ip address on linux CentOS 5.8 server. This post assumed that you have installed linux CentOS 5.8 with minimum type of installation. If you planned to run this CentOS as a server, it better to configure static ip address.

After you have installed CentOS 5.8 linux server, the default DHCP ip configuration will be as below :

[root@centos58 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Example:

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29:A1:17:AD
ONBOOT=yes

Please follow the following steps to configure static ip address on your linux CentOS 5.8 server.

1. Configure eth0 ip address and default gateway :

[root@centos58 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29:A1:17:AD
ONBOOT=yes
IPADDR=192.168.1.53
NETMASK=255.255.255.0
NETWORK=192.168.1.0
GATEWAY=192.168.1.1
TYPE=Ethernet
PEERDNS=yes
USERCTL=no

2. Restart Network interface:

[root@centos58 ~]# /etc/init.d/network restart

or

[root@centos58 ~]# service network restart

3. Configure DNS server:

[root@centos58 ~]# vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

How to Check the Number of Created User Account on Linux

Question :
How to check the number of created user on linux server?

Answer :

To check the created user on your linux machine, simply run the following command. This will includes the number of user for installed services such as apache, mysql or squid which will be installed automatically in order to run the particular services.

[root@centos62 ~]# cat /etc/passwd | wc -l
38

This command has been tested on linux centOS 6.2 server and may working on Redhat Enterprise linux and othr CentOS version. The result shows that there are 38 users on this linux CentOS 6.2 server.

How to Open the File in Read Only Mode on Linux

Question :
How to open a file on read only mode on linux?

Answer :
This command has been tested on Redhat Enterprise linux 6 (RHEL6) server. To open the file with vim in read only mode on linux, you need to run “vim -R” as below. Vim is enhanced version of vi editor that viewing the text file with coloring. “vim -R” is good command if you want to avoid accidentally deleted any important line as in read only.

Example :

[root@rhel6 ~]# vim -R /etc/passwd

read only mode

How Display Logged in User Information and Terminal number on Linux Server

In this post i will show on how to display logged in user information and terminal number on Linux server. This post provides practical examples for future references. This steps has been tested on Redhat Linux Enterprise server 6 and may working CentOS server as well.

1. “who am i” command is use to display the username of currently logged.

[root@rhel6 ~]# who am i
root     pts/1        2012-04-17 06:14 (192.168.1.52)

2. who command will display all the user currently logged in all terminals.

[root@rhel6 ~]# who
root     tty1         2012-04-17 04:29
root     pts/0        2012-04-17 04:29 (192.168.1.52)
root     pts/1        2012-04-17 06:14 (192.168.1.52)
root     pts/2        2012-04-17 06:01 (192.168.1.52)

3. tty command is used to display the terminal number of currently logged in terminals.

[root@rhel6 ~]# tty
/dev/pts/1

4. The w command shows who is logged in to the system and what they are doing.

[root@rhel6 ~]# w
 06:18:39 up  1:50,  4 users,  load average: 0.02, 0.02, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     -                04:29    1:48m  4.80s  4.78s ping www.google.com
root     pts/0    192.168.1.52     04:29    1:49m  0.02s  0.02s -bash
root     pts/1    192.168.1.52     06:14    0.00s  0.05s  0.01s w
root     pts/2    192.168.1.52     06:01   26.00s  0.11s  0.03s -bash

How to Install and Configure Bind9 DNS on Ubuntu 11.10

Bind is the most popular software and the most widely used Domain Name System (DNS) software on the Internet for providing DNS services. The name BIND stands for “Berkeley Internet Name Domain” and it’s an implementation of the DNS protocols. In this post i will show the steps how to install and configure Bind 9 DNS service on Ubuntu 11.10 linux server.

1. Install Bind9 :

ehowstuff@ehowstuff:~$ sudo apt-get install bind9 -y

2. Setup and configure zone with the name of ehowstuff.local

ehowstuff@ehowstuff:~$ sudo vim /etc/bind/named.conf.local

Add a DNS zone to BIND9. Edit named.conf.local as below :

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "ehowstuff.local" {
             type master;
             file "/etc/bind/db.ehowstuff.local";
        };
~

3. Copy and Use an existing zone file as a template:

ehowstuff@ehowstuff:/etc/bind$ sudo cp /etc/bind/db.local /etc/bind/db.ehowstuff.local

Edit the new zone file db.ehowstuff.local.

ehowstuff@ehowstuff:~$ sudo vim /etc/bind/db.ehowstuff.local

Change configuration as below :

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns.ehowstuff.local. root.ehowstuff.local. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.ehowstuff.local.
ns      IN      A       192.168.1.49
box     IN      A       192.168.1.49

4. Any changes that you’ve made to the zone file BIND9 will need to be restarted before it to take effect:

 
ehowstuff@ehowstuff:~$ sudo /etc/init.d/bind9 restart
 * Stopping domain name service... bind9                                            [ OK ]
 * Starting domain name service... bind9                                            [ OK ]

5. Make sure you own workstation or server pointing to dns server. In this case, this Ubuntu server pointed to itself since it’s running bind9.

ehowstuff@ehowstuff:~$ sudo vim /etc/resolv.conf
nameserver 127.0.0.1

6. test your bind9 server :

ehowstuff@ehowstuff:~$ nslookup
> set type=ns
> ehowstuff.local
Server:         127.0.0.1
Address:        127.0.0.1#53

ehowstuff.local nameserver = ns.ehowstuff.local.

How to Install Webmin 1.580 on Ubuntu 11.10

Webmin is a freeware program that provide web-based interface for system administration and system configuration tool for administrators. With Webmin you can setup user accounts, DNS, file sharing and etc. In this post, i will show how to install Webmin on Ubuntu 11.10 server.

1. Edit /etc/apt/sources.list file

ehowstuff@server:~$ sudo vi /etc/apt/sources.list
[sudo] password for ehowstuff:

Add this line at the bottom of sources.list file :

~
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
~

Save and exit the file :

:wq!

2. Download GPG key :

ehowstuff@server:~$ wget http://www.webmin.com/jcameron-key.asc
--2012-04-15 10:00:05--  http://www.webmin.com/jcameron-key.asc
Resolving www.webmin.com... 216.34.181.97
Connecting to www.webmin.com|216.34.181.97|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1320 (1.3K) [text/plain]
Saving to: `jcameron-key.asc'

100%[======================================>] 1,320       --.-K/s   in 0s

2012-04-15 10:00:06 (49.5 MB/s) - `jcameron-key.asc' saved [1320/1320]

Import GPG key :

ehowstuff@server:~$ sudo apt-key add jcameron-key.asc
OK

3. Install webmin :

ehowstuff@server:~$ sudo apt-get install webmin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl libnet-ssleay-perl
The following NEW packages will be installed:
  apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl libnet-ssleay-perl webmin
0 upgraded, 6 newly installed, 0 to remove and 57 not upgraded.
Need to get 16.2 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libnet-ssleay-perl i386 1.36-3 [206 kB]
Get:2 http://download.webmin.com/download/repository/ sarge/contrib webmin all 1.580 [15.8 MB]
Get:3 http://sg.archive.ubuntu.com/ubuntu/ oneiric/universe libauthen-pam-perl i386 0.16-2build1 [31.4 kB]
Get:4 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libio-pty-perl i386 1:1.08-1build1 [39.5 kB]
Get:5 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libapt-pkg-perl i386 0.1.24build3 [89.6 kB]
Get:6 http://sg.archive.ubuntu.com/ubuntu/ oneiric/universe apt-show-versions all 0.17 [32.9 kB]
Fetched 16.2 MB in 2min 58s (90.3 kB/s)
Selecting previously deselected package libnet-ssleay-perl.
(Reading database ... 50828 files and directories currently installed.)
Unpacking libnet-ssleay-perl (from .../libnet-ssleay-perl_1.36-3_i386.deb) ...
Selecting previously deselected package libauthen-pam-perl.
Unpacking libauthen-pam-perl (from .../libauthen-pam-perl_0.16-2build1_i386.deb) ...
Selecting previously deselected package libio-pty-perl.
Unpacking libio-pty-perl (from .../libio-pty-perl_1%3a1.08-1build1_i386.deb) ...
Selecting previously deselected package libapt-pkg-perl.
Unpacking libapt-pkg-perl (from .../libapt-pkg-perl_0.1.24build3_i386.deb) ...
Selecting previously deselected package apt-show-versions.
Unpacking apt-show-versions (from .../apt-show-versions_0.17_all.deb) ...
Selecting previously deselected package webmin.
Unpacking webmin (from .../archives/webmin_1.580_all.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up libnet-ssleay-perl (1.36-3) ...
Setting up libauthen-pam-perl (0.16-2build1) ...
Setting up libio-pty-perl (1:1.08-1build1) ...
Setting up libapt-pkg-perl (0.1.24build3) ...
Setting up apt-show-versions (0.17) ...
** initializing cache. This may take a while **
Setting up webmin (1.580) ...
Webmin install complete. You can now login to https://server.ehowstuff.local:10000/
as root with your root password, or as any user who can use sudo
to run commands as root.

4. Login Webmin using root access to the following URL :

https://server_ip:10000/
Example :
https://192.168.1.49:10000/

How to Check Memory Usage on Linux VPS Server

There are several ways on how to check the memory usage on linux virtual Private Server (VPS). This steps has been tested on linux CentOS 6.2 server and may workings on other linux server as well.

1. Check memory usage using “/proc/meminfo” command:

[root@centos62 ~]# cat /proc/meminfo

Output :

MemTotal:        1030888 kB
MemFree:          710372 kB
Buffers:           36444 kB
Cached:           191484 kB
SwapCached:            0 kB
Active:           180552 kB
Inactive:         104976 kB
Active(anon):      58048 kB
Inactive(anon):     2124 kB
Active(file):     122504 kB
Inactive(file):   102852 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:        141256 kB
HighFree:            280 kB
LowTotal:         889632 kB
LowFree:          710092 kB
SwapTotal:       2064376 kB
SwapFree:        2064376 kB
Dirty:              1388 kB
Writeback:             0 kB
AnonPages:         57628 kB
Mapped:            16512 kB
Shmem:              2564 kB
Slab:              21372 kB
SReclaimable:      15292 kB
SUnreclaim:         6080 kB
KernelStack:        1192 kB
PageTables:         1712 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2579820 kB
Committed_AS:     158252 kB
VmallocTotal:     122880 kB
VmallocUsed:        4264 kB
VmallocChunk:     111800 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       10232 kB
DirectMap2M:      897024 kB

2. Check memory usage using “free -m” command :

[root@centos62 ~]# free -m

Output :

             total       used       free     shared    buffers     cached
Mem:          1006        317        689          0         36        190
-/+ buffers/cache:         90        916
Swap:         2015          0       2015
[root@centos62 ~]#

3. Check memory usage using “top” command :

[root@centos62 ~]# top

Output :

Tasks:  84 total,   1 running,  83 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  2.4%sy,  0.0%ni, 96.0%id,  0.8%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:   1030888k total,   324996k used,   705892k free,    37324k buffers
Swap:  2064376k total,        0k used,  2064376k free,   194916k cached

4. Check memory usage using “vmstat” command :

[root@centos62 ~]# vmstat

Output :

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 701072  38236 198804    0    0    18    23   88   97  1  3 96  1  0

How to Install Remi yum Repository on CentOS 6.2 x86 and x86_64

There are several 3rd party repositories for CentOS 6 server. One of the popular one is remi repository. The Remi repository is a repository containing updated PHP and MySQL packages and is maintained by Remi. In this post, i will show you on how to install remi repository on linux CentOS 6.2 server

Import the RPM-GPG-KEY key and install remi rpm package :

[root@centos62 ~]# rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[root@centos62 ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Preparing...                ########################################### [100%]
   1:remi-release           ########################################### [100%]

To enable this repo, please change “enabled” value to 1 :

[remi]
name=Les RPM de remi pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority

[remi-test]
name=Les RPM de remi en test pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/test/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/test/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

How to Display the Number of Processors (vCPU) on Linux VPS

Question :

How to display the number of Virtual processor(vCPU) on linux Virtual Private Server (VPS) or Virtual Dedicated Server (VDS) ?

Answer :

To display the number of virtual processor(cpu) on linux vps, you have to run any of this command :

1. This command will display exact number of virtual cpu (vCPU) :

[root@centos62 ~]# cat /proc/cpuinfo | grep processor | wc -l
2

2. This command will grep any available vCPU. First cpu will start with 0.

Example of linux CentOS server with 1 vCPU :

[root@centos62 ~]# cat /proc/cpuinfo | grep processor
processor       : 0

Example of linux CentOS server with 2 vCPU :

[root@centos62 ~]# cat /proc/cpuinfo | grep processor
processor       : 0
processor       : 1

or this command will return the same result as steps (2).

[root@centos62 ~]# grep processor /proc/cpuinfo
processor       : 0

For additional information, you can display the number of cores on each CPU. Either Duo/Quad?

[root@centos62 ~]# cat /proc/cpuinfo |grep cpu\ cores |uniq
cpu cores       : 4

How to Check Concurrent user using Netstat Command on Linux Web Server

In this post, I will explain to you how to check concurrent users on a linux server. It was assumed that the web server is running on the default port 80. Netstat will print information about the Linux networking subsystem and express services listening on port Linux server along with details of any connection IP addresses is now made to them by using the port 80 .

List IP addresses connected to port 80 :

# netstat -tn 2>/dev/null | grep ':80 ' | awk '{print $5}' |sed -e 's/::ffff://' | cut -f1 -d: | sort | uniq -c | sort -rn | head

Calculate how many concurrent user that connected to port 80 :

# netstat -tn 2>/dev/null | grep ':80 ' | awk '{print $5}' |sed -e 's/::ffff://' | cut -f1 -d: | sort | uniq -c | sort -rn | head | wc -l

To get number of concurrent user and update every two seconds, type this command :

# watch "netstat -tn 2>/dev/null | grep ':80 ' | awk '{print $5}' |sed -e 's/::ffff://' | cut -f1 -d: | sort | uniq -c | sort -rn | head | wc -l"

How to Install and Configure Bind 9 as a Caching Server on Ubuntu 11.10

Bind is the most popular software and the most widely used Domain Name System (DNS) software on the Internet for providing DNS services. The name BIND stands for “Berkeley Internet Name Domain” and it’s an implementation of the DNS protocols. In this post i will show the steps how to install and configure Bind 9 to act as a caching server on Ubuntu 11.10 linux server.

root@ehowstuff:~# apt-get install bind9 -y

Example :

root@ehowstuff:~# apt-get install bind9 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  bind9-host bind9utils dnsutils libbind9-60 libcap2 libdns69 libisc62 libisccc60 libisccfg62
  liblwres60
Suggested packages:
  bind9-doc resolvconf rblcheck
The following NEW packages will be installed:
  bind9 bind9utils libcap2
The following packages will be upgraded:
  bind9-host dnsutils libbind9-60 libdns69 libisc62 libisccc60 libisccfg62 liblwres60
8 upgraded, 3 newly installed, 0 to remove and 56 not upgraded.
Need to get 1,592 kB of archives.
After this operation, 1,479 kB of additional disk space will be used.
Get:1 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main dnsutils i386 1:9.7.3.dfsg-1ubuntu4.1 [142 kB]
Get:2 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main bind9-host i386 1:9.7.3.dfsg-1ubuntu4.1 [53.9 kB]
Get:3 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main libisc62 i386 1:9.7.3.dfsg-1ubuntu4.1 [160 kB]
Get:4 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main libdns69 i386 1:9.7.3.dfsg-1ubuntu4.1 [676 kB]
Get:5 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main libisccc60 i386 1:9.7.3.dfsg-1ubuntu4.1 [18.0 kB]
Get:6 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main libisccfg62 i386 1:9.7.3.dfsg-1ubuntu4.1 [38.8 kB]
Get:7 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main liblwres60 i386 1:9.7.3.dfsg-1ubuntu4.1 [38.6 kB]
Get:8 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main libbind9-60 i386 1:9.7.3.dfsg-1ubuntu4.1 [23.0 kB]
Get:9 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libcap2 i386 1:2.21-2 [12.5 kB]
Get:10 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main bind9utils i386 1:9.7.3.dfsg-1ubuntu4.1 [102 kB]
Get:11 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main bind9 i386 1:9.7.3.dfsg-1ubuntu4.1 [327 kB]
Fetched 1,592 kB in 18s (88.4 kB/s)
Preconfiguring packages ...
(Reading database ... 50749 files and directories currently installed.)
Preparing to replace dnsutils 1:9.7.3.dfsg-1ubuntu4 (using .../dnsutils_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement dnsutils ...
Preparing to replace bind9-host 1:9.7.3.dfsg-1ubuntu4 (using .../bind9-host_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement bind9-host ...
Preparing to replace libisc62 1:9.7.3.dfsg-1ubuntu4 (using .../libisc62_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement libisc62 ...
Preparing to replace libdns69 1:9.7.3.dfsg-1ubuntu4 (using .../libdns69_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement libdns69 ...
Preparing to replace libisccc60 1:9.7.3.dfsg-1ubuntu4 (using .../libisccc60_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement libisccc60 ...
Preparing to replace libisccfg62 1:9.7.3.dfsg-1ubuntu4 (using .../libisccfg62_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement libisccfg62 ...
Preparing to replace liblwres60 1:9.7.3.dfsg-1ubuntu4 (using .../liblwres60_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement liblwres60 ...
Preparing to replace libbind9-60 1:9.7.3.dfsg-1ubuntu4 (using .../libbind9-60_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Unpacking replacement libbind9-60 ...
Selecting previously deselected package libcap2.
Unpacking libcap2 (from .../libcap2_1%3a2.21-2_i386.deb) ...
Selecting previously deselected package bind9utils.
Unpacking bind9utils (from .../bind9utils_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Selecting previously deselected package bind9.
Unpacking bind9 (from .../bind9_1%3a9.7.3.dfsg-1ubuntu4.1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ufw ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up libisc62 (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up libdns69 (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up libisccc60 (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up libisccfg62 (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up libbind9-60 (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up liblwres60 (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up bind9-host (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up dnsutils (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up libcap2 (1:2.21-2) ...
Setting up bind9utils (1:9.7.3.dfsg-1ubuntu4.1) ...
Setting up bind9 (1:9.7.3.dfsg-1ubuntu4.1) ...
Adding group `bind' (GID 113) ...
Done.
Adding system user `bind' (UID 105) ...
Adding new user `bind' (UID 105) with group `bind' ...
Not creating home directory `/var/cache/bind'.
wrote key file "/etc/bind/rndc.key"
#
 * Starting domain name service... bind9                                                     [ OK ]
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

The main configuration is stored in the following files:

root@ehowstuff:~# ls /etc/bind | grep named
named.conf
named.conf.default-zones
named.conf.local
named.conf.options

To configure bind9 to act as a caching server, all that is required is simply adding the IP numbers of your ISP’s DNS servers or alternatively you can use free google dns server as below :

root@ehowstuff:~# vim /etc/bind/named.conf.options

Uncomment and edit the following in /etc/bind/named.conf.options :

.
.
.
    forwarders {
                8.8.8.8;
         };
.
.
.

Start or restart caching named service :

As a root :

root@ehowstuff:~# /etc/init.d/bind9 restart
 * Stopping domain name service... bind9                                                     [ OK ]
 * Starting domain name service... bind9                                                     [ OK ]

or restart bind as normal user :

ehowstuff@ehowstuff:~$ sudo /etc/init.d/bind9 restart
[sudo] password for ehowstuff:
 * Stopping domain name service... bind9                                                     [ OK ]
 * Starting domain name service... bind9                                                     [ OK ]

Verify caching dns server completely working using dig command. Use dig command to query google.com :

root@ehowstuff:~# dig www.google.com

; <<>> DiG 9.7.3 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40642
;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 13, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.                        IN      A

;; ANSWER SECTION:
www.google.com.         86322   IN      CNAME   www.l.google.com.
www.l.google.com.       223     IN      A       209.85.175.99
www.l.google.com.       223     IN      A       209.85.175.103
www.l.google.com.       223     IN      A       209.85.175.104
www.l.google.com.       223     IN      A       209.85.175.105
www.l.google.com.       223     IN      A       209.85.175.106
www.l.google.com.       223     IN      A       209.85.175.147

;; AUTHORITY SECTION:
.                       14355   IN      NS      m.root-servers.net.
.                       14355   IN      NS      l.root-servers.net.
.                       14355   IN      NS      f.root-servers.net.
.                       14355   IN      NS      d.root-servers.net.
.                       14355   IN      NS      k.root-servers.net.
.                       14355   IN      NS      j.root-servers.net.
.                       14355   IN      NS      g.root-servers.net.
.                       14355   IN      NS      h.root-servers.net.
.                       14355   IN      NS      i.root-servers.net.
.                       14355   IN      NS      a.root-servers.net.
.                       14355   IN      NS      e.root-servers.net.
.                       14355   IN      NS      b.root-servers.net.
.                       14355   IN      NS      c.root-servers.net.

;; Query time: 14 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Apr  8 16:21:07 2012
;; MSG SIZE  rcvd: 359

How to Check Ubuntu Version

Question :
How to check Ubuntu Version that you are running?

Answer :
To print out the Ubuntu version you are running, you can run either one of the following commands :

1. Run “/etc/issue” :

root@ehowstuff:~# more /etc/issue
Ubuntu 11.10 \n \l

2. Run “lsb_release -a” :

root@ehowstuff:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.10
Release:        11.10
Codename:       oneiric