Wednesday, October 13, 2010

How to check Interface traffice on unix :

Using #snoop -d command on soalris
Using # tcpdump -vvi command on linux

Thursday, July 29, 2010

what is the meaning of " /dev/null 2>&1 "

we need to understand the theory first and then its upto you how and where you want to apply that theory. I'll try to explain above to you.

The greater-than (>) in commands like these redirect the program’s output somewhere. In this case, something is being redirected into /dev/null, and something is being redirected into &1.

Standard in, out and error:

There are three standard sources of input and output for a program. Standard input usually comes from the keyboard if it’s an interactive program, or from another program if it’s processing the other program’s output. The program usually prints to standard output, and sometimes prints to standard error. These three file descriptors (you can think of them as “data pipes”) are often called STDIN, STDOUT, and STDERR.

Sometimes they’re not named, they’re numbered! The built-in numberings for them are 0, 1, and 2, in that order. By default, if you don’t name or number one explicitly, you’re talking about STDOUT.

That means file descriptor 0 or fd0 denotes STDIN or standard input and file descriptor 1 or fd1 denotes STDOUT or standard output and file descriptor 2 or fd2 denotes STDERR or standard error.

You can see the command above is redirecting standard output into /dev/null, which is a place you can dump anything you don’t want (often called the bit-bucket), then redirecting standard error into standard output (you have to put an & in front of the destination when you do this).

The short explanation, therefore, is “all output from this command should be shoved into a black hole.” That’s one good way to make a program be really quiet!


example :

/opt/oracle/admin/pgrxd/analyze.ksh >> /opt/oracle/admin/pgrxd/analyze.log 2>&1

Thursday, July 22, 2010

/etc/vx/reconfig.d/state.d/install-db

Exact Error Message
vxvm:vxconfigd: ERROR: enable failed: Error in disk group configuration copies
Rootdg disk group has no configuration copies; transactions are disabled.
vxvm:vxdctl: ERROR: enable failed: Error in disk group configuration copies


Details:
If the install-db file exists in the /etc/vx/reconfig.d/state.d directory, Volume Manager will be disabled during boot. Volume Manager can be re-enabled during boot by removing the install-db file in the /etc/vx/reconfig.d/state.d directory.

In Volume Manager 3.1.1 with patch02 or patch03, if /etc/vx/reconfig.d/state.d/install-db exists, the Volume Manager boot file, /etc/vx/volboot, will be re-initialized. If any simple disk is included in rootdg, Volume Manager can not be started properly even if the file install-db is removed. This problem only occurred in Volume Manager 3.1.1 with patch02 or patch03, and the Volume Manager 3.1.1 Japanese version.

NOTE: This problem does not occur in Volume Manager 3.1.1 without patches and Volume Manager 3.2.

After the /etc/vx/reconfig.d/state.d/install-db file is created, an error message will not be displayed during the boot process. But, after the machine boots up, running the vxdctl enable command to enable the vxconfigd daemon will generate an error message as shown below:

# vxdctl enable
vxvm:vxconfigd: ERROR: enable failed: Error in disk group configuration copies
Rootdg disk group has no configuration copies; transactions are disabled.
vxvm:vxdctl: ERROR: enable failed: Error in disk group configuration copies

If simple disks are used in Volume Manager, run the following command to re-add all simple disk entries to the volboot file in order to re-enable the vxconfigd daemon. If more than one simple disk is used in Volume Manager, repeat the command until all of the simple disk entries have been added.

# vxdctl add disk

If no simple disks are used in Volume Manager, then the above step is not necessary. If the prior Volume Manager host ID was different than the operating system host name, it must run the following command to change the Volume Manager host ID, which is saved in the volboot file, to get Volume Manager started properly.

# vxdctl hostid

Then vxconfigd can be re-enabled by executing the following commands:

# vxdctl -k stop
# vxconfigd -d
# vxdctl enable

To fix the problem permanently, apply the following solution after installing the patch, but before reboot, to avoid the problem. If the problem has already occurred, apply the solution after recovering the volboot file using the steps above.

Solution

1. Find the following lines in the startup script /etc/init.d/vxvm-reconfig in line 165 to 171:

165> if [ -f $mkdbfile ]; then
166> xcmd vxiod set 10
167> xcmd $VOLD -k -r reset -m disable
168> xcmd vxdctl init
169> xcmd vxdctl initdmp
170> xcmd vxdg init rootdg
171> fi

2. Find the following line in line 222:

222> [ -f $reconfigfile ] || exit 0

3. Move the lines in step 1 to appear below the line in step 2

4. The modified vxvm-reconfig file will appear as shown below:


214> [ -f $reconfigfile ] || exit 0
215>
216> if [ -f $mkdbfile ]; then
217> xcmd vxiod set 10
218> xcmd $VOLD -k -r reset -m disable
219> xcmd vxdctl init
220> xcmd vxdctl initdmp
221> xcmd vxdg init rootdg
222> fi


5. Reboot

Linux Variables & Iteration, control and if statements

Linux Shell Programming

This section on shell programming, is a brief introduction to shell programming, and only talks about the bash shell. For more complete information, refer to "The CTDP Linux Programmer's Guide".

Linux Variables

When variables are used they are referred to with the $ symbol in front of them. There are several useful variables available in the shell program. Here are a few:

  • $$ = The PID number of the process executing the shell.
  • $? = Exit status variable.
  • $0 = The name of the command you used to call a program.
  • $1 = The first argument on the command line.
  • $2 = The second argument on the command line.
  • $n = The nth argument on the command line.
  • $* = All the arguments on the command line.
  • $# The number of command line arguments.

The "shift" command can be used to shift command line arguments to the left, ie $1 becomes the value of $2, $3 shifts into $2, etc. The command, "shift 2" will shift 2 places meaning the new value of $1 will be the old value of $3 and so forth.

Iteration, control and if statements


  • if - Used to execute one or more statements on a condition. An example:
    if [ ! -d /mnt ]  # be sure the directory /mnt exists
    then
    mkdir /mnt
    fi
  • case - Used to execute specific commands based on the value of a variable. An example:
    case $NUM of
    1)
    echo The number is 1
    ;;
    2)
    echo The number is 2
    ;;
    *)
    echo The number is not 1 or 2
    ;;
    esac
  • for - Used to loop for all cases of a condition. In the example below, it is used to copy all files found in /mnt/floppy to the /etc directory. The lines were numbered for reference with descriptions:
    1. The for loop statement will loop until all files have been found.
    2. A test to be sure the file is a normal file and not a directory.
    3. A comment line.
    4. This line extracts the name of the file from its full path pointed to by the variable $i and puts it in the variable $filename. The method used here is called parameter expansion and is documented in the bash man page. For more information on parameter expansion read the "Linux Programmer's Guide".
    5. This line sends a statement to the standard output, telling what file is being copied.
    6. This line performs the copy command using the -p option to preserve file attributes. Note: Much ability to perform script programming is couched in the ability to know and use the various commands, programs and tools available in Linux rather than a strict understanding of syntax. This is obvious to anyone who reads the system startup script files in /etc/rc.d and associated directories.
    7. This line ends the if statement.
    8. This line ends the for statement.
    1.  for i in /mnt/floppy/*; do
    2. if [ -f $i ]; then
    3. # if the file is there
    4. filename=${i#/mnt/floppy/}
    5. echo copying $i to /etc/$filename
    6. cp -p $i /etc/$filename
    7. fi
    8. done
  • until - Cycles through a loop until some condition is met. The syntax for the command is shown below:
    until [ expression ]
    do
    statements
    done
  • while - Cycles through a loop while some condition is met. The below example will cycle through a loop forever:
    while [ 1 ]
    do
    statement(s)
    done

Tests

There is a function provided by bash called test which returns a true or false value depending on the result of the tested expression. Its syntax is:

test expression

It can also be implied as follows:

[ expression ]

The tests below are test conditions provided by the shell:

  • -b file = True if the file exists and is block special file.
  • -c file = True if the file exists and is character special file.
  • -d file = True if the file exists and is a directory.
  • -e file = True if the file exists.
  • -f file = True if the file exists and is a regular file
  • -g file = True if the file exists and the set-group-id bit is set.
  • -k file = True if the files' "sticky" bit is set.
  • -L file = True if the file exists and is a symbolic link.
  • -p file = True if the file exists and is a named pipe.
  • -r file = True if the file exists and is readable.
  • -s file = True if the file exists and its size is greater than zero.
  • -s file = True if the file exists and is a socket.
  • -t fd = True if the file descriptor is opened on a terminal.
  • -u file = True if the file exists and its set-user-id bit is set.
  • -w file = True if the file exists and is writable.
  • -x file = True if the file exists and is executable.
  • -O file = True if the file exists and is owned by the effective user id.
  • -G file = True if the file exists and is owned by the effective group id.
  • file1 –nt file2 = True if file1 is newer, by modification date, than file2.
  • file1 ot file2 = True if file1 is older than file2.
  • file1 ef file2 = True if file1 and file2 have the same device and inode numbers.
  • -z string = True if the length of the string is 0.
  • -n string = True if the length of the string is non-zero.
  • string1 = string2 = True if the strings are equal.
  • string1 != string2 = True if the strings are not equal.
  • !expr = True if the expr evaluates to false.
  • expr1 –a expr2 = True if both expr1 and expr2 are true.
  • expr1 –o expr2 = True is either expr1 or expr2 is true.

The syntax is :

arg1 OP arg2

where OP is one of –eq, -ne, -lt, -le, -gt, or –ge. Arg1 and arg2 may be positive or negative integers or the special expression "–l string" which evaluates to the length of string.

An example script

The file below is an example file which demonstrates some of the testing as talked above along with several looping and control statements.

#! /bin/bash 
# Use the bash shell to run the script
# This is an example file to take entries from the user
# entries Version 1.0 May 22, 2000
DONE=no
ENTRIES="hello bye ls 1"
while [ $DONE = no ]
do
echo Valid entries are: $ENTRIES
read ENTRY # Read the variable ENTRY from the user
case $ENTRY in
1)
pwd
;;
hello)
echo How are you?
;;
bye)
echo exiting...
DONE=yes
;;
ls)
ls -al |more
;;
*)
echo $ENTRY is an unrecognized command.
;;
esac
done

gdb debugger commands

See the gdb(1) man page for more information on the gdb program. Below are listed some commands:

  • file - Loads the exe file.
  • kill - Terminates the program being debugged.
  • list - List sections of the source code.
  • next - Advances one line of source code in the current function and steps into other functions.
  • run - Executes the program that is being debugged.
  • quit - Ends gdb.
  • watch - Enables you to tell the value of a variable when it changes.
  • break - Set a break point.
  • make - Remake the exe program without quitting gdb.
  • shell - Run a UNIX shell command without leaving gdb.

While loop

Shell Script While Loop Examples

by Vivek Gite · 6 comments

Can you provide me a while loop control flow statement shell script syntax and example that allows code to be executed repeatedly based on a given boolean condition?

Each while loop consists of a set of commands and a condition. The general syntax as follows for bash while loop:

while [ condition ]
do
command1
command2
commandN
done
  1. The condition is evaluated, and if the condition is true, the command1,2…N is executed.
  2. This repeats until the condition becomes false.
  3. The condition can be integer ($i <>

ksh while loop syntax:

while [[ condition ]] ; do
command1
command1
commandN
done

csh while loop syntax:

     while ( condition )
commands
end

BASH while Loop Example

#!/bin/bash
c=1
while [ $c -le 5 ]
do
echo "Welcone $c times"
(( c++ ))
done

KSH while loop Example

#!/bin/ksh
c=1
while [[ $c -le 5 ]]; do
echo "Welcome $c times"
(( c++ ))
done

CSH while loop Example

#!/bin/csh
c=1
while ( $c <= 5 )
echo "Welcome $c times"
@ c = $c + 1
end

Another example:

#!/bin/csh
set yname="foo"
while ( $yname != "" )
echo -n "Enter your name : "
set yname = $<
if ( $yname != "" ) then
echo "Hi, $yname"
endif
end

"for" loop syntax

for loop syntax

Numeric ranges for syntax is as follows:

for VARIABLE in 1 2 3 4 5 .. N
do
command1
command2
commandN
done

This type of for loop is characterized by counting. The range is specified by a beginning (#1) and ending number (#5). The for loop executes a sequence of commands for each member in a list of items. A representative example in BASH is as follows to display welcome message 5 times with for loop:

#!/bin/bash
for i in 1 2 3 4 5
do
echo "Welcome $i times"
done

Sometimes you may need to set a step value (allowing one to count by two's or to count backwards for instance). Latest bash version 3.0+ has inbuilt support for setting up ranges:

#!/bin/bash
for i in {1..5}
do
echo "Welcome $i times"
done

Bash v4.0+ has inbuilt support for setting up a step value using {START..END..INCREMENT} syntax:

#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
for i in {0..10..2}
do
echo "Welcome $i times"
done

Sample outputs:

Bash version 4.0.33(0)-release...
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times

The seq command (outdated)

WARNING! The seq command print a sequence of numbers and it is here due to historical reasons. The following examples is only recommend for older bash version. All users (bash v3.x+) are recommended to use the above syntax.

The seq command can be used as follows. A representative example in seq is as follows:

#!/bin/bash
for i in $(seq 1 2 20)
do
echo "Welcome $i times"
done

There is no good reason to use an external command such as seq to count and increment numbers in the for loop, hence it is recommend that you avoid using seq. The builtin command are fast.

Three-expression bash for loops syntax

This type of for loop share a common heritage with the C programming language. It is characterized by a three-parameter loop control expression; consisting of an initializer (EXP1), a loop-test or condition (EXP2), and a counting expression (EXP3).

for (( EXP1; EXP2; EXP3 ))
do
command1
command2
command3
done

A representative three-expression example in bash as follows:

#!/bin/bash
for (( c=1; c<=5; c++ ))
do
echo "Welcome $c times..."
done

Sample output:

Welcome 1 times
Welcome 2 times
Welcome 3 times
Welcome 4 times
Welcome 5 times

How do I use for as infinite loops?

Infinite for loop can be created with empty expressions, such as:

#!/bin/bash
for (( ; ; ))
do
echo "infinite loops [ hit CTRL+C to stop]"
done

Conditional exit with break

You can do early exit with break statement inside the for loop. You can exit from within a FOR, WHILE or UNTIL loop using break. General break statement inside the for loop:

for I in 1 2 3 4 5
do
statements1 #Executed for all values of ''I'', up to a disaster-condition if any.
statements2
if (disaster-condition)
then
break #Abandon the loop.
fi
statements3 #While good and, no disaster-condition.
done

Following shell script will go though all files stored in /etc directory. The for loop will be abandon when /etc/resolv.conf file found.

#!/bin/bash
for file in /etc/*
do
if [ "${file}" == "/etc/resolv.conf" ]
then
countNameservers=$(grep -c nameserver /etc/resolv.conf)
echo "Total ${countNameservers} nameservers defined in ${file}"
break
fi
done

Early continuation with continue statement

To resume the next iteration of the enclosing FOR, WHILE or UNTIL loop use continue statement.

for I in 1 2 3 4 5
do
statements1 #Executed for all values of ''I'', up to a disaster-condition if any.
statements2
if (condition)
then
continue #Go to next iteration of I in the loop and skip statements3
fi
statements3
done

This script make backup of all file names specified on command line. If .bak file exists, it will skip the cp command.

#!/bin/bash
FILES="$@"
for f in $FILES
do
# if .bak backup file exists, read next file
if [ -f ${f}.bak ]
then
echo "Skiping $f file..."
continue # read next file and skip cp command
fi
# we are hear means no backup file exists, just use cp command to copy file
/bin/cp $f $f.bak
done

The hostid of the machine is stored in /etc/xv/volboot

The hostid of the machine is stored in /etc/xv/volboot

Solaris 9 ==> Tto Connect SAN Disks -> luxadm

Sun Solaris 9 Commands to Connect SAN Disks

$ man luxadm

Maintenance Commands luxadm(1M)

NAME
luxadm - administration program for the Sun Enterprise Net-
work Array (SENA), RSM, SPARCstorage Array (SSA) subsystems,
and individual Fiber Channel Arbitrated Loop (FC_AL) devices

SYNOPSIS
luxadm [ options ... ] subcommand [ options ... ] enclo-
sure [ ,dev ] | pathname ...
-----------------------------------------


There are always a bunch of strange commands to connect a server to SAN disks. In my case, I’m running Solaris 9, using QLogic Fibre Channel cards, and connecting to an IBM DS4300.

1) Connect the Solaris server SAN disks. After I made the connection, the GUI that allows me to zone the SAN recognized the QLogic connections, and I zoned the LUNs.

If you need more detailed instructions, here are some potentially useful posts: How to Zone a Brocade SAN Switch and How to Zone IBM DS4000 SAN Disks.

2) Scan your disks, and it should show up as a new disk when you run “format”.

Solaris# devfsadm
Solaris# format

My result: No new disks. Sigh.

3) Run a bunch of cryptic but useful diagnostic commands:

To see your HBA ports and whether you’re connected:

Solaris# luxadm -e port
Found path to 3 HBA ports
/devices/pci@8,700000/SUNW,qlc@2/fp@0,0:devctl CONNECTED
/devices/pci@8,700000/SUNW,qlc@2,1/fp@0,0:devctl CONNECTED
/devices/pci@8,600000/SUNW,qlc@4/fp@0,0:devctl CONNECTED

To see your disks:

Solaris# luxadm probe

To see your HBA ports (type fc-private, below) and their connected disks (type disk):

Solaris# cfgadm -al

Ap_Id Type Receptacle Occupant Condition
c8 fc-private connected configured unknown
c8::200800a0b8199b3b disk connected configured unknown
c9 fc-private connected configured unknown
c9::200900a0b8199b3b disk connected configured unknown

4) Force Fibre Channel SAN disk rescan, since everything looks connected and okay. Use your device path from “luxadm -e port” output.

Solaris# luxadm -e forcelip /devices/pci@8,700000/SUNW,qlc@2/fp@0,0:devctl
Solaris# luxadm -e forcelip /devices/pci@8,700000/SUNW,qlc@2,1/fp@0,0:devctl
Solaris# luxadm -e forcelip /devices/pci@8,600000/SUNW,qlc@4/fp@0,0:devctl

5) Rerun format command.

Solaris # format

AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w500000e0107111e1,0
1. c1t1d0 t2
/pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w500000e01070d761,0
2. c7t600A0B801019B1B2002032A5489C60F3d0
/scsi_vhci/ssd@g600a0b801019b1b2002032a5489c60f3


Also click

http://www.iti.cs.tu-bs.de/cgi-bin/UNIXhelp/man-cgi?luxadm+1M


Here are some of the commands I use, also attached stuff for old ssa.

FCAL Disks
luxadm probe (discovers fcal)
luxadm display Enclosure (displays information on fcal box)
luxadm reserve /dev/rdsk/c#t#d#s# (reserves device so it can’t be accessed)
luxadm -e offline /dev/rdsk/c#t#d#s# (takes a device offline)
luxadm -e bus_quiesce /dev/rdsk/c#t#d#s# (quiesce the bus)
luxadm -e bus_unquiesce /dev/rdsk/c#t#d#s# (unquiesce the bus)
luxadm -e online /dev/rdsk/c#t#d#s# (bring the disk device back online)
luxadm release /dev/rdsk/c#t#d#s# (unreserved the device for use)
luxadm remove_device BAD,f2 (removes a device from slot f2 on enclosure BAD)
luxadm insert_device BAD,f2 (hot plug a new device to slot f2 on enclosure BAD)

SSAADM (for old ssa drawers)
ssaadm display c# (displays ssa on controller)
ssaadm display /dev/rdsk/c#t#d#s# (display drive information)
ssaadm start /dev/rdsk/c#t#d#s# (spin up a specific drive)
ssaadm stop /dev/rdsk/c#t#d#s# (spin down a specific drive)
ssaadm start –t 3 c# (spin up all drives in tray 3 on controller )
ssaadm stop –t 3 c# (spin down all drives in tray 3 on controller)
ssaadm start c# (spin up all drives in array)
ssaadm stop c# (stop all drives in array)

Wednesday, July 21, 2010

Linux / Unix Command: route

To add routedetails :
Example :-

#route add -net 192.168.13.0 netmask 255.255.255.0 gw 192.168.13.1 dev eth0

Full Description:-

Linux / Unix Command: route


NAME

route - show / manipulate the IP routing table

SYNOPSIS

route [-CFvnee]
route
[-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw] [metric N] [mss M] [window W] [irtt I] [reject] [mod] [dyn] [reinstate] [[dev] If]
route
[-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm] [metric N] [[dev] If]
route
[-V] [--version] [-h] [--help]

DESCRIPTION

Route manipulates the kernel's IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig(8) program.

When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.

OPTIONS

-A family
use the specified address family (eg `inet'; use `route --help' for a full list).
-F
operate on the kernel's FIB (Forwarding Information Base) routing table. This is the default.
-C
operate on the kernel's routing cache.
-v
select verbose operation.
-n
show numerical addresses instead of trying to determine symbolic host names. This is useful if you are trying to determine why the route to your nameserver has vanished.
-e
use netstat(8)-format for displaying the routing table. -ee will generate a very long line with all parameters from the routing table.
del
delete a route.
add
add a new route.
target
the destination network or host. You can provide IP addresses in dotted decimal or host/network names.
-net
the target is a network.
-host
the target is a host.
netmask NM
when adding a network route, the netmask to be used.
gw GW
route packets via a gateway. NOTE: The specified gateway must be reachable first. This usually means that you have to set up a static route to the gateway beforehand. If you specify the address of one of your local interfaces, it will be used to decide about the interface to which the packets should be routed to. This is a BSDism compatibility hack.
metric M
set the metric field in the routing table (used by routing daemons) to M.
mss M
set the TCP Maximum Segment Size (MSS) for connections over this route to M bytes. The default is the device MTU minus headers, or a lower MTU when path mtu discovery occured. This setting can be used to force smaller TCP packets on the other end when path mtu discovery does not work (usually because of misconfigured firewalls that block ICMP Fragmentation Needed)
window W
set the TCP window size for connections over this route to W bytes. This is typically only used on AX.25 networks and with drivers unable to handle back to back frames.
irtt I
set the initial round trip time (irtt) for TCP connections over this route to I milliseconds (1-12000). This is typically only used on AX.25 networks. If omitted the RFC 1122 default of 300ms is used.
reject
install a blocking route, which will force a route lookup to fail. This is for example used to mask out networks before using the default route. This is NOT for firewalling.
mod, dyn, reinstate
install a dynamic or modified route. These flags are for diagnostic purposes, and are generally only set by routing daemons.
dev If
force the route to be associated with the specified device, as the kernel will otherwise try to determine the device on its own (by checking already existing routes and device specifications, and where the route is added to). In most normal networks you won't need this.

If dev If is the last option on the command line, the word dev may be omitted, as it's the default. Otherwise the order of the route modifiers (metric - netmask - gw - dev) doesn't matter.

EXAMPLES

route add -net 127.0.0.0
adds the normal loopback entry, using netmask 255.0.0.0 (class A net, determined from the destination address) and associated with the "lo" device (assuming this device was prviously set up correctly with ifconfig(8)).
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
adds a route to the network 192.56.76.x via "eth0". The Class C netmask modifier is not really necessary here because 192.* is a Class C IP address. The word "dev" can be omitted here.
route add default gw mango-gw
adds a default route (which will be used if no other route matches). All packets using this route will be gatewayed through "mango-gw". The device which will actually be used for that route depends on how we can reach "mango-gw" - the static route to "mango-gw" will have to be set up before.
route add ipx4 sl0
Adds the route to the "ipx4" host via the SLIP interface (assuming that "ipx4" is the SLIP host).
route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4
This command adds the net "192.57.66.x" to be gatewayed through the former route to the SLIP interface.
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
This is an obscure one documented so people know how to do it. This sets all of the class D (multicast) IP routes to go via "eth0". This is the correct normal configuration line with a multicasting kernel.
route add -net 10.0.0.0 netmask 255.0.0.0 reject
This installs a rejecting route for the private network "10.x.x.x."

OUTPUT

The output of the kernel routing table is organized in the following columns
Destination
The destination network or destination host.
Gateway
The gateway address or '*' if none set.
Genmask
The netmask for the destination net; '255.255.255.255' for a host destination and '0.0.0.0' for the default route.
Flags
Possible flags include
U (route is up)
H (target is a host)
G (use gateway)
R (reinstate route for dynamic routing)
D (dynamically installed by daemon or redirect)
M (modified from routing daemon or redirect)
A (installed by addrconf)
C (cache entry)
! (reject route)
Metric
The 'distance' to the target (usually counted in hops). It is not used by recent kernels, but may be needed by routing daemons.
Ref
Number of references to this route. (Not used in the Linux kernel.)
Use
Count of lookups for the route. Depending on the use of -F and -C this will be either route cache misses (-F) or hits (-C).
Iface
Interface to which packets for this route will be sent.
MSS
Default maximum segement size for TCP connections over this route.
Window
Default window size for TCP connections over this route.
irtt
Initial RTT (Round Trip Time). The kernel uses this to guess about the best TCP protocol parameters without waiting on (possibly slow) answers.
HH (cached only)
The number of ARP entries and cached routes that refer to the hardware header cache for the cached route. This will be -1 if a hardware address is not needed for the interface of the cached route (e.g. lo).

Friday, June 11, 2010

RAM Size in Solaris Server

The command to find the Ram size in solaris is

#prtconf | grep Mem



Solaris is a virtual memory system. The total physical memory can be seen using prtconf. as said by user . Memory is allocated in units called pages, and you can use the pagesize command to know the number of bytes per page:

% /usr/bin/pagesize

Actually Physical memory usage can be classified into four groups:
Kernel memory mapped into kernel address space
Process memory is mapped into a process address space
Filesystem cache memory that is not mapped into any address space
Free memory that is not mapped into any address space

Let us see how to find the memory usage of each:

The simplest summary of kernel memory usage comes from sar.
% sar -k 1

Process memory consists of an address space divided into segments. The segments can be viewed using /usr/proc/bin/pmap on any system running Solaris 2.5 or later.

% /usr/proc/bin/pmap

File system has cache memory and this is the part of memory that is invisible.
The memps -m command lists the files that are cached in order
# memps -m | more

Free memory that is not mapped into any address space

Wednesday, June 2, 2010

How to check Physical Memory utlization on solaris

To check Physical memory utlization on soalris :-

check Total physical memory:

# prtdiag -v | grep Memory

# prtconf | grep Memory

---

check Free physical Memory:

# top (if available)

# sar -r 5 10
Free Memory=freemen*8 (pagesize=8k)

# vmstat 5 10
Free Memory = free

---

For swap:

# swap -s
# swap -l


or

#prstat -s size --> wil show the memory utlization for each process

Thursday, May 13, 2010

To come out from solaris zone console

To come out from solaris zone console use "~."

i102sptest console login:
i102sptest console login: ~.
[Connection to zone 'i102sptest' console closed]
root@iss2s102 #

Tuesday, May 4, 2010

To change ownership/permissions for a soft-link files

To change ownership/permissions for a soft-link files :-

use -h option

#chown -h ownername:groupname link-filename

#chown -h oracle:oracle file1

Monday, May 3, 2010

Backup an entire hard disk using dd command

Backup an entire hard disk using dd command :-

The ' dd ' command is one of the original Unix utilities and should be in everyone's tool box. It can strip headers, extract parts of binary files and write into the middle of floppy disks

; it is used by the Linux kernel Makefiles to make boot images. It can be used to copy and convert magnetic tape formats, convert between ASCII and EBCDIC, swap bytes, and force to upper and lowercase.

For blocked I/O, the dd command has no competition in the standard tool set. One could write a custom utility to do specific I/O or formatting but, as dd is already available almost everywhere, it makes sense to use it.

Like most well-behaved commands, dd reads from its standard input and writes to its standard output, unless a command line specification has been given. This allows dd to be used in pipes, and remotely with the rsh remote shell command.

Unlike most commands, dd uses a keyword=value format for its parameters. This was reputedly modeled after IBM System/360 JCL, which had an elaborate DD 'Dataset Definition' specification for I/O devices. A complete listing of all keywords is available from GNU dd with

# dd --help

For more options check dd man page

Using dd you can create backups of an entire harddisk

or just a parts of it. This is also usefull to quickly copy installations to similar machines. It will only work on disks that are exactly the same in disk geometry, meaning they have to the same model from the same brand.

full hard disk copy

dd if=/dev/hdx of=/dev/hdy
dd if=/dev/hdx of=/path/to/image
dd if=/dev/hdx | gzip > /path/to/image.gz

Hdx could be hda, hdb etc. In the second example gzip is used to compress the image if it is really just a backup.

Restore Backup of hard disk copy

dd if=/path/to/image of=/dev/hdx

gzip -dc /path/to/image.gz | dd of=/dev/hdx

MBR backup

In order to backup only the first few bytes containing the MBR and the partition table you can use dd as well.

dd if=/dev/hdx of=/path/to/image count=1 bs=512

MBR restore

dd if=/path/to/image of=/dev/hdx

Add "count=1 bs=446" to exclude the partition table from being written to disk. You can manually restore the table

Thursday, April 15, 2010

To set an IP address permanently in Solaris

just edit two files
#vi /etc/hostname.hme0
change the ip address as required in this file
#vi /etc/netmasks
change the netmask as required in this file

UPDATE: It seems that Solaris 10 now checks the /etc/inet/ipnodes file first before the /etc/hosts file to set the IP. So, if the IP is currently set in /etc/inet/ipnodes, you will have to change it there as well.

* IP -> /etc/hosts
* Netmask -> /etc/netmasks
* Gateway -> /etc/defaultrouter
* IP (again) -> /etc/inet/ipnodes (This is new in Solaris 10)
* DNS Servers -> /etc/resolv.conf