Thursday, August 12, 2010

How To Install Oracle On RHEL5

The most popular database(DB) software known to man is Oracle. There are some other commercial and open source Databases such as1. MS-Sql(from Microsoft)
2. DB2(from IBM)
3. PostgreSQL(its a open source SW) 
4. Mysql(my favorate one and good for small/medium organisations)
5. Sybase
Etc.. 



Do you want to know more about other DB names? Have look at below link, i create a squered link for you.Ans : http://www.google.com/squared/search?q=mssql&items=mysql&items=oracle&items=PostgreSQL&items=db2&items=njsql
In this post we will come to know that how to install Oracle on RHEL5?
Step1 : Before installing Oracle it require following packages to be installed on the machine.
1. compat-gcc
2. compat-libstdc++
3. compat-db
4. make-3.79
5. binutils-2.11.90.0.8-12
6. gcc-3.2
7. openmotif-2.2
8. setarch-1.3

All these packages are there in RHEL5 DVD so you just implement YUM server for easy installation of the above packages, other wise you have to install one by one with rpm command which will create a lot of dependencies.

Step2 : Set kernel parameters by editing /etc/sysctl.conf or using sysctl -w command. As follows.

Note : When ever you edit any files take backup of that files before editing those files.
kernel.shmall = 268435456
kernel.sem = 250 32000 100 128
kernel.shmmax = 2147483647

kernel.shmmni = 4096
kernel.shmall = 2097152
fs.file-max = 65536

net.ipv4.ip_local_port_range = 1024 65000
kernel.sem=250 32000 100 128
net.core.rmem_default = 4194304

net.core.rmem_max= 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
#cp /etc/sysctl.conf /etc/sysctl.conf.org
#vi /etc/sysctl.conf

After entering the above values save and exit the file
or use sysctl -w to edit kernel paramaters.
Here I will just give one example how to edit sysctl.conf using sysctl -w command.

Suppose I want to edit kernel.sem value just execute below command.
#/sbin/sysctl -w kernel.sem=”250 32000 100 128”

Step3 :
 After editing the file check if any issue is there or not by printing the sysctl content.
#sysctl -p
Note1 : Most part of the installation is done by oracle user. Untill and unless specified. Only at the end of installation we require to run two scripts which will 
set path variables.

Note2 : If you are installing Oracle on remote machine we have to export the display to local machine or we have to take vnc to the remote machine.

Step4 : Create Group name
#groupadd dba
Step5 : Creat oracle user with group equal to dba and home directory equal to 
/oracle
#useradd -d /oracle -g dba oracle



Installation :Step1 : Copy Oracle software to some folder. Change the directory to bin directory as showen below.cd /test/database
Here you will find run Installer script which you should execute in oracle user and this should be done in GUIit self(so in order to execute this command you have to export display or take vnc to remote machine). Here in this document I have taken vnc connection to remote machine where I am installing OS. For those who don't have vnc export display as follows.

Step2 : Exporting display, you have to execute this command as oracle user on remote machine where you are going to install oracle. And one more thing. Display should be exported to local machine where you are going to preform your installation.
DISPLAY = system name/ip: 0.0
Export DISPLAY

Note : System name/ip in the above display command is the ip/system name of your local machine.
Image.

















































































































































































The above screen shot shows that you have to run the script. And this should be run only by root.
Step3 : Script to be run by root user.
[root@test oracle]# /oracle/oracle/product/10.2.0/db_1/root.shRunning Oracle10 root.sh script...
The following environment variables are set as :ORACLE_OWNER= oracle

ORACLE_HOME= /oracle/oracle/product/10.2.0/db_1

Enter the full pathname of the local bin directory : [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...

Copying oraenv to /usr/local/bin ...

Copying coraenv to /usr/local/bin ...

Entries will be added to the /etc/oratab file as needed by 


Database Configuration Assistant when a database is created

Finished running generic part of root.sh script.

Now product-specific root actions will be performed.

Once run this as root go to oracle user gui login and say ok.. to exit..











































Step4 : Now we have to check whether oracle is installed perfectly or not. We have to set ORACLE_HOME variable for oracle user .bash_profile file to export oracle bin directory as follows. So that we can start/stop oracle service with lsnrctl edit .bashrc file for the oracle user.$vi ~/.bash_profile

PATH=$PATH:$HOME/bin

export PATH
ORACLE_HOME=/oracle/oracle/product/10.2.0/db_1

PATH=$PATH:$ORACLE_HOME/bin

ORACLE_SID=orcl

export PATH ORACLE_HOME ORACLE_SID
Save and exit the file. Once done we have to source the .bash_profile file. Then start the oracle service by using below command.
[oracle@v-itig42 ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-MAR-2010 07:12:13

Copyright (c) 1991, 2005, Oracle. All rights reserved.

TNS-01106: Listener using listener name LISTENER has already been started
For checking status.[oracle@v-itig42 ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-MAR-2010 07:12:01

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC3)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date 05-MAR-2010 06:10:20

Uptime 0 days 1 hr. 1 min. 41 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

Listener Log
File /oracle/oracle/product/10.2.0/db_1/network/log/listener.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC3)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=v-itig42.persistent.co.in)(PORT=1523)))

Services Summary :
Service "PLSExtProc" has 1 instance(s).

Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).

Instance "orcl", status READY, has 1 handler(s) for this service...

Service "orclXDB" has 1 instance(s).

Instance "orcl", status READY, has 1 handler(s) for this service...

Service "orcl_XPT" has 1 instance(s).

Instance "orcl", status READY, has 1 handler(s) for this service...

The command completed successfully

Step5 : Connect to Oracle sql database(and this should be done only as oracle user).
[oracle@v-itig42 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Mar 5 07:22:56 2010

Copyright (c) 1982, 2005, Oracle. All rights reserved.

SQL>

This sql> prompt indicates you have sucessfully connected..

SQL> conn sys@iasdb as sysdba
Enter password :Connected to an idle instance.SQL>If the database is not started it will show the messages as connected to idle instance.
4. To start the database executeSQL> startup
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1301536 bytes
Variable Size 262677472 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
Database opened.
SQL>
5. To check the name of the databaseSQL> select name from v_$database;

NAME
---------
IASDB

How To Kill Defunct Or Zombie Process

"defunct" processes is also known as a "zombie" processes. A Zombie process is referred as dead processwhich is receding on your system thought its completed executing. In one shot we can say its a dead processes. This process will be in your process table and consuming your memory. Having more defunct process will consume your memory which intern slows your system. We have to kill the defunct process in order to free RAM and make system stable.
Why defunct process are created?Ans : When ever a process ends all the memory used by that process are cleared and assigned to new processbut due to programming errors/bugs some processes are still left in process table. These are created when there is no proper communication between parent process and child process.
Some FAQ?
1. How to find a defunct process?
And : Grep defunct value in ps -ef output
#ps -ef grep defunct2. How can i kill a defunct process?And : Just use kill command#kill defunct-pid
3. Still not able to kill? 

Ans : Then use kill -9 to force kill that process#kill -9 defunct-pid
4. Still have an issue in killing it? 

Ans : Then try to kill its parent id and then defunct.#kill parent-id-of-defunct-pid
Then

#kill -9 parent-id-of-defunct-pid
5. Still having defunct? 

Ans : If you still find defunct process eating up RAM then last and final solution is to reboot your machine.

6.What is orphan process?
Ans : An orphan process is said to be a process which runs though parent process is terminated, these process do not know what to do and when to terminate.
7. What is difference between orphan and defunct processes?Ans : A defunct process is a dead process where there is no execution happening where as orphan process is a live process which is still in execution state but don't have parent process

I am having a system which daily creates defunct process, I cannot sit and kill these process on daily basis. 


How to get rid of this problem?Ans : Just write a shell script to grep defunct process and kill them by putting this script in corntab.

Linux Terminal Server Project (LTSP)

Now I will tell you how we can configure LTSP server for our lab with telnet, rdesktop, shell and startx ( for Linux log in).
Step1 :a. Make sure DHCP server is installed and running properly on your system
b. Now install tftp server also on your machine and you can find it’s rpm on your Redhat DVD 
(5.0)
c.
 Now install rdesktop rpm and it is also you can find on your redhat DVD (5.0)
d. Configure your windows xp system with full terminal and remote desktop support for distribute rdesktopalso over the network so that client can be run 
windows xp.
e.
 Now download ltsp-4.1.0-1_2.iso image from it’s website (
http://ltsp.mirrors.tds.net/pub/ltsp/isos/)and my package size is 100MB (apprx.).
f.
 Now I am making dir test in filesystem (/) and extract this package in test directory
g. Now open readme file from test folder and read instructions carefully on 
how to install this package.
h.
 After installation complete you need to configure ltsp server .
Step 2 :Configure tftp for ltsp server

TFTP : TFTP is a simple file transfer protocol, used by ltsp to transfer the kernel to the workstations.
XINETD : Xinetd is a powerful replacement for inetd, with advanced features, used by ltsp to start tftp.
Open the file # vim /etc/xinetd.d/tftp and make disable = no. Otherwise tftp not work.
service tftp
{
Disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}

Now restart xined service#service xinetd restart
Step3 :Configure nfs for ltsp server
Open the file #vim /etc/exports and enter following lines in it./opt/ltsp 192.168.0.0/255.255.255.0(ro,no_root_squash,sync)
/var/opt/ltsp/swapfiles 192.168.0.0/255.255.255.0(rw,no_root_squash,async)

Now restart nfs service#service nfs restart
#chkconfig nfs on (for service start automatically on every bootup)
Step4 :Configure dhcpd.conf for ltsp server
Now you need to configure dhcpd.conf file and here is example of my file.#vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
# option routers 192.168.0.1;
# option subnet-mask 255.255.255.0;
# option nis-domain "domain.org";
option domain-name "san.com";
option domain-name-servers 192.168.0.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
option log-servers 192.168.0.1;
option root-path "192.168.0.1:/opt/ltsp/i386";

If you use thes lines here then every system on your network can boot from #ltsp server but if you want more security then remove this line and then only #that system can boot that’s hardware address will declare in“host ws001” #section with static ip address.
filename "/lts/2.4.26-ltsp-2/pxelinux.0";
range dynamic-bootp 192.168.0.128 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;

If you want to use static IP address for your workstation the following section and modify to suit your network. Then, duplicate this section for each workstation that needs a static IP address.

host ws001 {
hardware ethernet 00:20:ED:75:9A:EC;
fixed-address 192.168.0.2;
filename "/lts/2.4.26-ltsp-2/pxelinux.0";
}
}
Step5 :Configure lts.conf for ltsp server
Now you need to configure #vim /opt/ltsp/i386/etc/lts.conf file for client.
Here is example of my 
lts.conf file
[Default]
SERVER = 192.168.0.1
RDP_SERVER = 192.168.0.50
XSERVER = auto
X_MOUSE_PROTOCOL = "PS/2"
X_MOUSE_DEVICE = "/dev/psaux"
X_MOUSE_RESOLUTION = 400
X_MOUSE_BUTTONS = 3
USE_XFS = N
X_COLOR_DEPTH = 24 # it is for xp terminal server
X_MODE_0 = 1024x768
RUNLEVEL = 5
LDM_REMOTECMD = /etc/X11/xinit/Xsession
SCREEN_01 = startx
SCREEN_02 = telnet
SCREEN_3 = shell
SCREEN_4 = rdesktop

Note : Here I will explain some options of this file.

SERVER : Here you I have to enter your ltsp server ip address.

RDP_SERVER : If you want to run remote desktop connection on xp then you have enter IP address. Of your xp terminal server. Otherwaise remove this option.
LDM_REMOTECMD :/etc/X11/xinit/XsessionWhen I was trying to running startx on client machine it was showing white screen only for solving this problem I copied this. Option from internet and paste it here and my problem solved.

Source : The LTSP client screen will still not display because LTSP expects a file /etc/X11/Xsession to exist on the server. In RHEL5 this corresponds to /etc/X11/xinit/Xsession .This can be fixed by specifying the
environment variable LDM_REMOTECMD in /opt/ltsp/i386/etc/lts.conf:[192.168.250.20]LDM_REMOTECMD = /etc/X11/xinit/Xsession.About SCREEN :The most interesting parameter here is SCREEN_01. The default is startx, which specifies that the workstation should boot up in a graphical X display, but there are a number of interesting possibilities. 

The other options are :· telnet : When the workstation boots up in this mode, it waits for you to press, then starts a TELNET session to the host. Obviously, your TELNET server must be running for this. (Many offices use SSH by default.). You have to enter your telnet server IP in /opt/ltsp/i386/etc/screen.d/telnet file.
· shell : This starts a local command shell, meaning local to the workstation, not to the server. From here, you could telnet or ssh to your server, or start a graphical login by typing startx. This mode is generally used for testing. It's also a great way to see the virtual Linux machine that gets created as part of the LTSP boot process.
· rdesktop : Setting SCREEN_01 to this fires up rdesktop, a Linux-based Windows Terminal Server Client, which means it uses RDP (remote desktop protocol) to communicate with and run remote Windows sessions from your Linux thin client.
How Many Screen's ?Ans : Of course, the fact that this last variable is labeled SCREEN_01 leads up to the obvious Question: What about SCREEN_02? Or SCREEN_03?Earlier in this chapter, I told you about running your main X session on virtual terminal session 7, while thesecond X session (started with an X -query) ran on virtual terminal 8. You can do something similar withthin-client workstations by modifying the lts.conf file to include more than one SCREEN definition. Here is the example from my own Server :
SCREEN_01 = startx.

You want to enter your telnet server IP in /opt/ltsp/i386/etc/screen.d/telnet file
SCREEN_02 = telnet
SCREEN_03 = shell
SCREEN_04 = rdesktop

The first virtual terminal (accessible by pressing ) runs the graphical login served up via XDMCP. The second virtual terminal () runs a TELNET session with a prompt saying “Screen:2 – Press to establish a connection to the server…” Finally, the third screen () sits at a shell prompt.
In a default LTSP installation, all these screen definitions can be found in the /opt/ltsp/i386/etc/screen.d directory. Each is a shell script and easy to read and understand. You could, if you so wish, create your own screen definitions to better suit your own environment.
These types of screen modifications can be done globally or on a client-by-client basis. In the next chapter, you are going to look at just what sorts of things you can do with workstations. I am also going to show you how you can run a not quite so thin, Linux thin client from a Windows desktop.
Step6 :Configure xdm-config file for ltsp server
Next, open the file /etc/X11/xdm/xdm-config and comment out the line :DisplayManager.requestPort: 0And Edit This file also because sometime it makes problem
/opt/ltsp/i386/etc/xdm/xdm-config and comment out the line :
DisplayManager.requestPort: 0Step7 :Enable Remote Login in RedHat so that client able access login screen.[root@racdb2 ~]# gdmsetup
After starting the gdmsetup utility, click the Remote tab. Under the Remote tab, change the Style pull-down menu selection from 'Remote login disabled' to 'Same as Local' :After configuring remote access to the GDM login manager, select the Security tab. Under the Security tab,

I have checked the options:· Allow local system administrator login
· Allow remote system administrator login

Exit from the gdmsetup utility and restart the GDM service :[root@racdb2 ~]# /usr/sbin/gdm-restart
OR 


Enable remote login via configure files.Use the following steps to enable the services and modify the files necessary to configure the XDMCP:1. To do this, edit the /etc/X11/xdm/Xaccess file and open the connection to hosts by un-commenting the line:
#* #any host can get a login window
or

Enter individual IP addresses of selected hosts.
SuSE users
 can do the same by editing the file 
/usr/X11R6/lib/X11/xdm/Xaccess.
2. Next, open the file /etc/X11/xdm/xdm-config and comment out the line:
DisplayManager.requestPort: 0
And this file also because sometime it makes problem
/opt/ltsp/i386/etc/xdm/xdm-config

3. Make sure to run the program xdm as the "root" user account.# xdm &
4. If the things still do not work, you may need to reboot the server or restart the xdm if it was already running. The xdm command (X Display Manager) manages a collection of X displays, which may be on the local host or remote servers. The design of the xdm command was guided by the needs of X terminals as well as the X Consortium standard XDMCP (the X Display Manager Control Protocol).
GDM Login Manager
Users running Red Hat Enterprise Linux 5, CentOS 5, or Oracle Enterprise Linux Release 5 will need to use the GDM login manager as XDM is no longer supported.
First, edit the file /etc/gdm/custom.conf and add the following two entries:
[xdmcp]
Enable=true
[security]
DisallowTCP=false
AllowRemoteRoot=true
Next, restart X Windows:
[root@racdb2 ~]# init 3
[root@racdb2 ~]# init 5
Step8 :It is an optional step because some time client show syslog error after booting it means your server is not configure for accept remote logs so you want to configure some lines for that-#vim /etc/sysconfig/syslogand add the -r option as below:SYSLOGD_OPTIONS=”-r –m 0”Now restart syslog service#service syslog restartAnd now open file /opt/ltsp/i386/etc/lts.conf and add the following line:SYSLOG_HOST = 192.168.0.1 #your syslog server ipMore Examples of configure files in different way /etc/dhcpd.conf

SNORT(IDS/IPS) Configuration and Implemenation


Lets start how to install SNORT which is An Intrusion detection system (IDS) and an Intrusion Prevention System (IPS). We tested installation of SNORT on RHEL5.
Step1 : Download following packageslibpcap-1.0.0.tar.gzpcre-8.00.tar.gzlibnet-1.0.2a.tar.gz (This is optional package if you want SMB popup alerts on window’s machines.)snort-2.8.5.1.tar.gzacid-0.9.6b23.tar.gz
Note : Don’t try to install SNORT through rpm packages, try to install them from source packages because there will be so many dependencies. And install the above packages in the same order to resolve dependencies.
Step2 : Untar packages one by one.#tar xvfz packagename.tar.gz
Step3 : Change the directory to libpcap-1.0.0 and Just run ./configure shell script, this will check system attributes and generate make file, which is used to install libpcap package as following.
#cd libpcap-1.0.0
#./configuration
#make
#make install
Note : If anything goes wrong please search that error message in google..
Step4 : After installing libpcap install pcre package for doing regular expression query in checking the packet capture to match multiple entries. First change the directory to pcre-8.00 then start executing following commands
#cd ../pcre-8.00
#./configure
#make
#make check
#make install
Step5 : Now install libnet package..#cd ../libnet-1.0.2a
#./configure
#make
#make check
#make install
Step6 : Now install the important package in our game of implementing IDS/IDP ie our SNORT package. Just follow below commands to install SNORT. You have to be careful in this step because we can install SNORT in standalone system or a complete system with DB/web server/acid support. If you are planning to install SNORTin standalone just execute ./configure after changing to snort-2.8.5.1 directory. But here I am going to build a complete SNORT system will all the capabilities. Before that we should know what are the content of snort source directory. Please get some knowledge on it and read the required readme files in doc/ folder.
Note : Before installing SNORT do the following things (Before installation you can do this).
1. Make sure that you copy etc/ content in source directory to /etc directory
2. Create /var/log/ snort directory for snort logging activity (remember we have to mention this path in main configuration file, in our case it will be /etc/snort/etc/snort.conf.
3. Create /etc/snort/rules directory for creating rules files for snort.
#mkdir /etc/snort
# cp -ar ./etc /etc/snort/
#mkdir /var/log/snort
# mkdir /etc/snort/rules
Now start installing SNORT
# ./configure --with-mysql --with-snmp --enable-smbalerts --enable-flexresp
#make
#make check
#make install
Hmm..! good we are done with the installation of SNORT
So in the next post I will show you how to configure, integrate SNORT with Mysql and ACID.

Server configuration file syntax Checking commands


I have planned to write this post some long time ago, now the time has come to do it.

Basically configuring servers in Linux/*nix include editing of configuration files and saving them. Once editing the files if any syntax error is there and when we start the service they will show some wearied errors which we cant resolve.
For counter attacking this type of issues for each service there will be one command to check this syntax errors before starting of the service/server, I have collected these commands from my experience and from some of my friends. Please feel free to comment on this if you know some other commands so that I will update my post.

SSHD server check for syntax error
=========================
sshd -t
FTP server check for syntax error
=========================
#vsftpd
DNS server check for syntax error
==========================

For checking syntax errors in main configuration file..
#named-checkconf main-config-file

Example:
#named-checkconf named.conf
Syntax OK

#named-checkzone domain zonefile-loc
Example:
#named-checkzone example.com /var/named/chroot/var/named/exaple-zone.frd

SAMBA server check for syntax error
=============================
#testparm

APACHE server check for syntax error

=============================
httpd -t
For virtual hosts
httpd -t -D DUMP_VHOSTS
TCP Wrappers check for syntax error
============================
tcpdchk
tcpdchk -v

Postfox server check for syntax error
============================
postfix checkpostfix -vv
LIGHTTPD 
server check for syntax error
=============================
lighttpd -t -f /etc/lighttpd/lighttpd.conf

Squid 
server check for syntax error
==========================
squid -k check
squid -k parse


NAGIOS server check for syntax error
====================================
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Suresh's DIG Notes


In this post i am going to teach How to use DIG and DIG by examples.
DIG is one of the most important tool in debugging DNS server related issues.

Some points to be noted about DIG.
1. DIG full-form/abbreviation is Domain Information Groper

2. DIG can work on command line or as well in batch mode

3. DIG supports IDN convections too.

4. DIG is more advanced than older tools such as nslookup and host commands.
5. DIG output have so much information than any other tool, such as Question/Answer/Authority sections(which we are going to discuses in this post)

Usage1 : Using DIG in basic form.
#dig hostname 

Example :[root@ts6741 ~]# dig www.google.com
; <<>> DiG 9.3.3rc2 <<>> www.google.com
; (1 server found);; global options: printcmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52434;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
http://www.google.com/. 43200 IN A 200.99.187.2
;; AUTHORITY SECTION:
http://www.google.com/. 43200 IN NS ns2.google.com.
http://www.google.com/. 43200 IN NS ns3.google.com.
http://www.google.com/. 43200 IN NS ns1.google.com.
;; ADDITIONAL SECTION:
ns1.google.com. 43200 IN A 222.54.11.86
ns2.google.com. 43200 IN A 220.225.37.222
ns3.google.com. 43200 IN A 203.199.147.233
;; Query time: 1 msec
;; SERVER: 222.54.11.86#53(222.54.11.86)
;; WHEN: Wed Nov 18 18:31:12 2009
;; MSG SIZE rcvd: 152[root@ts6741 ~]# 

Here important points to know
1. DIG version in Green (9.3).
2. Question section in blue (Here it will show what you asked DIG to show up?).
3. Answer secession in red (which will show you the answer for the query you asked).
4. Authority section in brown (Which will show you who given the answer).
5. Addition Section in light blue (It will show you if any additional info that DNS server provided).
6. Total Query time in light green (Which will show how much time it takes to provide the answer).
7. Server info in light brown (This will show what the port DNS server is working).
8. Query execute date and time in dark red.

Usage2 : Using DIG for reverse lookup entries#dig –x ipadd

Example :#dig –x 192.56.78.1

Usage3 : Digging with specified DNS server. Let me put it in this way. My dns server is not working properly and I want to test some server details, for this DIG will allow you to provide a DNS sever so that DIG will get information about the required system from that DNS server. We can provide DNS server by using symbol as shown below.#dig @ns-server hostname
Example :
#dig @223.125.43.67 http://www.google.com/ 

Note : Here in this example my dig will not check /etc/resolve.conf file for default DNS server entry, it will just request details of http://www.google.com/ from a outside world DNS server ie 223.125.43.67

Usage4 : To dig a DNS server on a perticular port,where DNS server is running .
#dig @223.125.43.67 -p 2345 www.google.com

Note:here 223.125.43.67 is the DNS server and port 2345 where that DNS service is running.

Usage5 : To check the trace of the path.#dig http://www.google.com/ +trace

Usage6 : To get mail server details#dig mx www.google.com
Note : This will provied all the mail servers in google.com

Usage7: To get Name server details
#dig ns http://www.google.com/

Note : 
This will provide all the Name Server records.

Linux interview questions

1)How to compile Apache?

2)Users come to you and they will be saying mail server is very slow, what are the necessary steps you will take to resolve this issue?

3)Which are the configuration files associate with DNS server and client?

4)Where you will provide ISP details for your network?

5)How you will configure Squid proxy?

6)How you will block pron sites using Squid proxy?

7)Give me details how to configure mail support for NAGIOS?

8)Can you use NAGIOS to send SMS? how to do that?

9)What is web-min?
A) Webmin is a web-based system configuration tool for OpenSolaris, Linux and other Unix-like systems.

10)How you will do kernel compilation? Explain each step?

11)What is the difference between SGID, SUID and sticky bit?

12)How to restrict users to set password with complexity ?

13)How do you monitor system performance?

14)Which are the configuration files of FTP server?

15)What are the different types of FTP servers?

16)What is the difference between active FTP and passive FTP?

17)How you will configure FTP in DMZ?

18)What is the use of htaccess file?

19)how do you configure website authentication for user logins?

20)Give me the steps to configure sendmail.

21)How to block particular network not to access my sendmail server?

22)How to send duplex/half duplex etc to the network card?

23)Can a web server have multiple ip add? if yes why? if no why?

24)How to configure multiple ip address for a web server?

25)What is the difference between VMWare and XEN?

26)Explain me the difference between ext2 and ext3

27)How do you configure route in Linux server?

28)How do you make routes permanent in Linux server?

29)Why you want to change your job?

30)What is an inode?

31)what is the difference between soft link and hard link?

32)How to get info about the files which are not accessed from last 30days?



what is the difference between soft link and hard link?
what are the advantages with NFS?
What is difference between LILO and GRUB?
How you will troubleshoot if boot partation is missing?
What is crontab?
How you will install MYsql in different ways?
What is the difference beween Mysql5.0 and 4.0 versions?
the host is unreachable how you will resolve this issue?
there is no firewall the host is in same network and dns server is working fine?
what is mii tool will do?
what is the advantage of lsof command?
How you can compile kernel?
What is CVS server?
what are your day today activity?
how you will create users on NIS server when the server is in production envernoment?
Actually there is one partaion with 20gb mounted on /data. Users are unable to create files and data due to disk full so when you logged in to server and checked the space by using du -k its showing.

Linux Interview Questions:Disk management

 1) How to creat swap if you dont have free partation?
this is some what tricky question if you are new to Linux Administration
here is the command to create swap if you dont have free partation
before doing this you have switchoff the swap
swapoff -a
dd if=/dev/zero of=/root/swapfile bs=1k count=1024
swapon filename

2)How to see swap details?
   cat /proc/swap
   free

3)How to see/get info about RAM in ur system
   free
   cat /proc/meminfo

4)What is the difference between ext2 and ext3
  I)ext3=ext2+journaling
 "journaling" is an add-on to a filesystem that records changes as they are made.
II)ext2 files system is fast
III)less disk writes
IV)ext2 file system in less stable/secure
V)ext2 file system required to run fsck command if the system get crashed

5)How to convert ext2 file system to ext3?
   tune2fs -j /dev/hda1
6)How convert ext3 file system to ext2
   tune2fs -O^has-journal /dev/hda1

7)What is default block/chunk size for PV
   4MB

8)what is the command to update the diskquota on file system
   mount -o remount,rw /home

9)What is the partation type number for swap,RAID,LVM?
   82(swap),fd(RAID),8e(LVM)

10)What is the default block site for ext2,ext3,LVM,RAID?

11)What is the difference between LVM1 and LVM2?

12)What is difference between RAID0,1,5?


Linux Interview Questions:Basic


1)How do you find out what’s your shell? - echo $SHELL
2)What’s the command to find out today’s date? - date
3)How do you find out the current directory you’re in? - pwd
4)How do you find out your own username? - whoami/who am i
5)How do you send a mail message to somebody? - mail surendra.anne@gmail.com -s ‘Your subject’ -c ‘test@gmail.com‘
6)What’s the command to find out users on the system? - who/users
7)How do you remove a file? - rm
8)How do you remove a - rm -rf
9)How do you count words, lines and characters in a file? - wc
10)How do you search for a string inside a given file? - grep string filename
11)How do you search for a string inside a directory? - grep string *
12)How do you search for a string in a directory with the subdirectories recursed? - grep -r string *
13)What are PIDs? - They are process IDs given to processes. A PID can vary from 0 to 65535.
14)How do you list currently running process? - ps
15)How do you stop a process? - kill pid
16)How do you find out about all running processes? - ps -ag
17)How do you stop all the processes, except the shell window? - kill 0
18)How do you fire a process in the background? - ./process-name &
19)How do you refer to the arguments passed to a shell script? - $1, $2 and so on. $0 is your script name.
20)What’s the conditional statement in shell scripting? - if {condition} then … fi
21)How do you do number comparison in shell scripts? - -eq, -ne, -lt, -le, -gt, -ge
22)How do you test for file properties in shell scripts? - -s filename tells you if the file is not empty, -f filename tells you whether the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for excitability
23)How do you do Boolean logic operators in shell scripting? - ! tests for logical not, -a tests for logical and, and -o tests for logical or.
24)How do you find out the number of arguments passed to the shell script? - $#
25)What’s a way to do multilevel if-else’s in shell scripting? - if {condition} then {statement} elif {condition} {statement} fi
26)How do you write a for loop in shell? - for {variable name} in {list} do {statement} done
27)How do you write a while loop in shell? - while {condition} do {statement} done
28)How does a case statement look in shell scripts? - case {variable} in {possible-value-1}) {statement};; {possible-value-2}) {statement};; esac
29)How do you read keyboard input in shell scripts? - read {variable-name}
30)How do you define a function in a shell script? - function-name() { #some code here return }
31)How does getopts command work? - The parameters to your script can be passed as -n 15 -x 20.Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.

Wednesday, August 11, 2010

NMAP With Examples


NMAP is one of the most important tool. Which checks which ports are open on a machine.
Some important to note about NMAP
  1. NMAP abbreviation is network mapper
  2. NMAP is used to scan ports on a machine, either local or remote machine (just you require ip/hostname to scan).
  3. NMAP is can be installed on windows, Sun Solaris machines too.
  4. NMAP can be used to scan large networks, remember I am saying large networks.
  5. NMAP can be used to get operating system details, uptime, software used for a service and its version no, vender of network card and uptime of that system too(Don’t worry we will see all these things in this post.
  6. Please do not try to use NMAP on machines which you don’t have permission.
  7. Can be used by hackers to scan for systems for venerability.
  8. Just a funny note : You can see this NMAP used by trinity in Matrix-II, when she tries to hack in to electric grid super computer.
Note : NMAP man pages one of the best man pages I have come across. It is explained in such a way that even new user can understand it easily and one more thing it is even having examples in to how to use NMAP in different situations, when you have time read it. You will get lots of information.

Example1 : Using NMAP in normal way, i.e. to scan a particular system for open ports
#nmap hostname
Example2 : Scanning for a single port on a machine
#nmap –p 22 hostname
This will scan for 22 port is open on a host or not. And here –p indicates port.
Example3 : For scanning only ports
#nmap –F hostname-F is for fast scan and this will not do any other scanning like IP address, hostname, operating system, and uptime etc. It’s very much fast as it said in man pages.
Example4 : For scanning only TCP ports
#nmap –sT hostname
Here s is for scanning and is for only scanning of TCP ports

Example5 : For scanning only UDP ports#nmap –sU hostnameHere indicates UDP port scanning
Exmaple6 : Scanning for ports and to get what is the version of different services running on that machine
#nmap –sV hostname
V indicates version of each network service running on that host

Example7 : To check which protocol is supported by the remote machine#nmap –sO hostname
Example8 : To scan a system for operating system and uptime details# nmap -O hostname
-O
 is for operating system scan along with default port scan

Example9 : Scanning a network#nmap networkID/subnetmaskFor the above command you can try in this way#nmap 192.168.0.0/24
Some sites to refer (not for practical examples, but for to get good concept):nmap.org : official site for our NMAP en.wikipedia.org/wiki/Nmap 
Please Comment your thoughts regarding this post:-)