Showing posts with label UNIX. Show all posts
Showing posts with label UNIX. Show all posts

Unix command to find class in jar | windows command to search class in jars

Below are the sample commands to find out required class is there in the jar files of current directory and its sub-dirs.

Unix : 

find . -type f -name '*.jar' -print0 |  xargs -0 -I '{}' sh -c 'jar tf {} | grep com/sun/net/ssl/HostnameVerifier.class &&  echo {}'
find . -type f -name '*.jar' -print0 |  xargs -0 -I '{}' sh -c 'jar tf {} | grep HostnameVerifier.class &&  echo {}'
Ex :
[kg6378@bldv0014 jdk1.6.0_20]$ find . -type f -name '*.jar' -print0 |  xargs -0 -I '{}' sh -c 'jar tf {} | grep com/sun/net/ssl/HostnameVerifier.class &&  echo {}'
com/sun/net/ssl/HostnameVerifier.class
./jre/lib/jsse.jar

[kg6378@bldv0014 jdk1.6.0_20]$ find . -type f -name '*.jar' -print0 |  xargs -0 -I '{}' sh -c 'jar tf {} | grep HostnameVerifier.class &&  echo {}'
com/sun/deploy/security/CertificateHostnameVerifier.class
./jre/lib/deploy.jar
javax/net/ssl/HostnameVerifier.class
javax/net/ssl/HttpsURLConnection$DefaultHostnameVerifier.class
sun/net/www/protocol/https/DefaultHostnameVerifier.class
com/sun/net/ssl/HostnameVerifier.class
./jre/lib/jsse.jar

Windows : 


forfiles /S /M *.jar /C "cmd /c jar -tvf @file | findstr /C:"HostnameVerifier.class" && echo @path"


C:\Users\kg6378\Desktop\jdk-7u79-windows-x64\tools>cd C:\Krish\MyDocs\SWS\Jdk1.6
.0_14

C:\Krish\MyDocs\SWS\Jdk1.6.0_14>forfiles /S /M *.jar /C "cmd /c jar -tvf @file |
 findstr /C:"HostnameVerifier.class" && echo @path"

  3517 Thu May 21 09:19:20 EDT 2009 com/sun/deploy/security/CertificateHostnameV
erifier.class
"C:\Krish\MyDocs\SWS\Jdk1.6.0_14\jre\lib\deploy.jar"
   194 Thu Feb 05 13:54:20 EST 2009 javax/net/ssl/HostnameVerifier.class
   618 Thu Feb 05 13:54:22 EST 2009 javax/net/ssl/HttpsURLConnection$DefaultHost
nameVerifier.class
   384 Thu Feb 05 13:54:22 EST 2009 sun/net/www/protocol/https/DefaultHostnameVe
rifier.class
   272 Thu Feb 05 13:54:32 EST 2009 com/sun/net/ssl/HostnameVerifier.class
"C:\Krish\MyDocs\SWS\Jdk1.6.0_14\jre\lib\jsse.jar"

C:\Krish\MyDocs\SWS\Jdk1.6.0_14>





Read more


wget command to copy directory containing multiple sub directories and files

wget command to copy directory containing multiple sub directories and files

Below is a simple WGET command which will download a folder recursively with its sub directories and files. 

wget -r  --no-parent https://ABC.com/projects/build/prebuild/offerings/20130910-0610%25krishna.g_p00027/ --http-user XYZ--http-passwd XYZ--no-check-certificate

Simple explanation : 

-r : Recursively copies 

--no-parent : Do'nt copy the parent siblings. only downloads from the specified subdirectory and downwards hierarchy.

--http-user : Username 

--http-passwd : Password 

--http-passwd : Accept https certificates if any .

Read more


Shell Script Tips -1

The below shell scripts are typical example codes which helps us to understand certain frequently used codes.

1. How to get the absolute or full path while calling another shell script from one shell script.

#!/bin/sh
source $(readlink -f "ifix_config.sh") uninstall

The above code snippet calls another shell script by name ifix_config.sh. which is available in the same directory of current script.
Abosolute path will be used with the readlink -f option there. uninstall isa parameter passed to it.

2. How to check how many parameters are passed in to a shell script..
if [ $# != "1" ]; then
    echo "Usage: ifix_config.sh install or ifix_config.sh uninstall"
    exit
else
    ....
    ....
$# represents total number of parameters passed to a shell script when called.
In the above example code if at least one parameter is not passed it throws a message and exits.

3. How to check if a variable is set or not . How to check if a viariale has empty string ?

    LOCALE_CODE=$LANG
    if [ -z $LOCALE_CODE ];
        then JAZZSM_SYSTEM_LOCALE="en_US"
    fi   

In the above example snippet we are setting some value for LOCALE_CODE if in case it is not set for some reason -z option with if condition returns true
so in above example if it( if [ -z $LOCALE_CODE ] ) is true  it will set it to en_US

4. How to get the parent directory path of a file or directory ?

    PresentDir=`dirname $PWD` 

When dirname is given a pathname, it will delete any suffix beginning with the last slash ('/') character and return the result.
For example:

 $ dirname /usr/home/carpetsmoker/dirname.wiki
   /usr/home/carpetsmoker

5. How to get the only filename when absolute path is given ?

Example

    $ basename /home/jsmith/base.wiki
    base.wiki

    $ basename /home/jsmith/base.wiki .wiki
    base

    IFIX_NO=`basename $PWD`
    0001

6.     How to read a properties file in shell script  ?

    # Reading settings.properties to find IM Install location
    IM_HOME=`sed '/^\#/d' $PropertiesFile | grep 'product.install.location'  | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
    echo IM Install Location is : $IM_HOME
   
    Example :
    $PropertiesFile contents are like below ..
    -------------------------------------------
    #Fri, 01 Mar 2013 02:59:37 -0500

    product.was.user=smadmin
    product.jdbc.lib.path=/opt/IBM/JazzSM/lib/db2
    product.data.location=/var/ibm/InstallationManager
    product.install.location=/opt/IBM/InstallationManager/eclipse
    -------------------------------------------
    The while process is to Scan through the file to get an individual property

    This works well if you just want to read a specific property in a Java-style properties file. Here's what it does:

    * Remove comments (lines that start with '#') >> sed '/^\#/d' myprops.properties
    * Grep for the property >>  grep 'someproperty' 
    * Get the last value using >> tail -n 1
    * Strip off the property name and the '=' (using {{cut -d "=" -f2-}) to handle values with '=' in them).

     sed '/^\#/d' myprops.properties | grep 'someproperty'  | tail -n 1 | cut -d "=" -f2-

    It can also be handy to strip off the leading and trailing blanks with this sed expression:

    s/^[[:space:]]*//;s/[[:space:]]*$//

    Which makes the whole thing look like this:

    sed '/^\#/d' myprops.properties | grep 'someproperty'  | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'

Reference

7.  How to check file existance before running it ?

[ -f "$SCRIPT_LOCATION/myshellscript.sh" ] && . "$SCRIPT_LOCATION/myshellscript.sh"   

Having quotes for the file path eliminates issues arise out of spaces in the path.

8. How to read input values through shell script ?

    # Ask for WAS credentials
    if [ -z "${JAZZSM_WAS_USERNAME}" ]
    then
      echo -n "${wasUserNamePrompt}: "
      read JAZZSM_WAS_USERNAME
    fi

echo -n "${wasUserNamePrompt}: "     >> it helps to prompt user with particular string before commandline prompt while running shell script, in order to resolve wasUserNamePrompt string we need to run its correspinding properties file before this call .
For example config_messages.sh has text like below , and when it is run before the above command it will resolve this value.

#!/bin/sh

#NLS_MESSAGEFORMAT_NONE
#NLS_ENCODING=UTF-8

wasUserNamePrompt="Enter the Websphere Application Server user name:"

wasPasswordPrompt="Enter the Websphere Application Server password:"

Read more


How to mount iso images on AIX and Linux?

Let's assume if u have some ISO image files as  : IBM-jazzsm-launchpad-1.1-aix64.iso and IBM-was-8.5.0.1-aix64.iso
and U want to mount them to two different directories which are freshly created under /mnt like below .. .WAS_ISO and JAZZ_ISO

U have to run below commands to mount them now ...
AIX :
bash-3.2# ls
IBM-jazzsm-launchpad-1.1-aix64.iso  IBM-was-8.5.0.1-aix64.iso
bash-3.2# loopmount -i IBM-jazzsm-launchpad-1.1-aix64.iso -o "-V cdrfs -o ro" -m /mnt/JAZZ_ISO/
bash-3.2# loopmount -i IBM-was-8.5.0.1-aix64.iso  -o "-V cdrfs -o ro" -m /mnt/WAS_ISO/
bash-3.2#

Linux :
Ex :
1) Create the directory i.e. mount point:
    # mkdir -p /mnt/disk
2) Use mount command as follows to mount iso file called disk1.iso:
    # mount -o loop disk1.iso /mnt/disk
--
Thanks & Regards
Krishna
http://www.krishnababug.com/

Read more


Shell script to pass arguments and validation of arguments in side shell

The below is a simple shell script snippet which accepts two kinds of parameters(1. start 2. -start) while running.
How to validate these parameters and how to run the shell script accordingly is the main motto :)
set -x
if [[ "$1" == "start" || "$1" == "-start" ]]; then
echo "code for start action"
else
echo "Please input valid arguments"
echo "Usuage: setup.sh start or setup.sh -start "
exit
fi

Hope this helps in passing parameters to installer like scripts. 
I observed the behavior of the same script differ in different shells like k shell and bash shell.
 

 
 

Read more


shell script to upload/ftp files to remote machine automatically

Shell script to upload files using FTP from one machine to remote machine automatically

The below simple shell script will automate the FTP steps, to upload file(s) from one machine to other easily ...
edit it according to ur convinece ..

nc184120:/opt/builds # cat ftp.sh
#!/bin/bash

HOST='9.142.193.94'
USER='root'
PASSWD='havefun'

ftp -i -n $HOST <<kris
user ${USER} ${PASSWD}

binary
cd /opt
put cds_db2_admin.sql
quit
kris

nc184120:/opt/builds # ./ftp.sh
Connected to virgo.in.ibm.com.
220-FTP Server (user 'krishna.g@in.ibm.com')
220
331-Password:
331
230-230 User root logged in.
230
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
250 CWD command successful.
local: cds_db2_admin.sql remote: cds_db2_admin.sql
229 Entering Extended Passive Mode (|||64693|)
150 Opening BINARY mode data connection for cds_db2_admin.sql.
100% |**************************************************************************************************************************************|  1101       6.73 MB/s    00:00 ETA
226 Transfer complete.
1101 bytes sent in 00:00 (4.48 KB/s)
221-You have transferred 1101 bytes in 1 files.
221-Total traffic for this session was 1601 bytes in 1 transfers.
221-Thank you for using the FTP service on virgo.
221 Goodbye.



Read more


shell script to print/check directory permissions on Unix

Shell script to print/check directory permissions on Unix
Here is a small shell script which will print a directory permissions and other details...
Basically I want to check whether a directory has the read write permissions for the user?
I am using here a simple commonsense that a read write permissions will make the octal permissions of it more than 600 for sure .. that's it.
d rwx rwx rwx
d rw- --- ---
   420 000 000
   6     0      0
   rwx r-x r-x
   7 5 5
So it should be always greater than 600 for a directory to have read write permissions always.
Basically I'm using stat tool to find the permissions of a dir
Ex : check stat for /opt/a
nc184120:/opt # stat /opt/a
  File: `/opt/a'
  Size: 48              Blocks: 0          IO Block: 4096   directory
Device: 802h/2050d      Inode: 101912      Links: 2
Access: (0155/d--xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-07-01 22:53:59.845347264 -0700
Modify: 2010-07-01 01:45:43.769709152 -0700
Change: 2010-07-01 01:46:14.790993200 -0700

So the above script doesn't have read or write permissions.

Shell script  :
nc184120:/opt # cat per.sh
dir="/opt/a"
echo "Checking the permissions for $dir"
stat $dir
echo "##############################################"
if [ `stat -c "%a" $dir` -ge 600 ] ; then
     echo "$dir has Read Write permissions."
else
     echo "$dir has no read write permissions."
fi

and the output looks like below ...
nc184120:/opt # ./per.sh
Checking the permissions for /opt/a
  File: `/opt/a'
  Size: 48              Blocks: 0          IO Block: 4096   directory
Device: 802h/2050d      Inode: 101912      Links: 2
Access: (0155/d--xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-07-01 22:53:59.845347264 -0700
Modify: 2010-07-01 01:45:43.769709152 -0700
Change: 2010-07-01 01:46:14.790993200 -0700
##############################################
/opt/a has no read write permissions.


Read more


Generate mutiple insert commands in sql file using shell script

The following small shell script will generate a SQL file which contains multiple insert statements.
The shell script will add unique numbers for each primary key object in the insert statements.

######################################################################
i=1270803816866
k=1
while [ $k -le 4 ]
do
echo "insert into CDSSCHEMA.PLAN_DESCRIPTION (PLAN_ID,PACKAGE_ID,LOCAL_IP,REMOTE_IP,STATUS,PLANCREATIONTIME,USERID) values ('$i','1270803791784','9.124.158.200','9.124.158.200',1,'2010-04-09 09:04:21.979898','CDS_Administrator')" >> dummydata.sql
let i="i+1"
let k="k+1"
done
####################################################################
Put the above lines of code in shell script and run it at the shell to generate mutiple insert statements according to ur need in  the SQL file dummydata.sql
Don't forget to add your better ideas to improve this script in form of comments.

Read more


AWK SED Shell scripts and one liners commands examples

Handy AWK and SED ..frequently used one liners.

In this post I want to continuously update the most frequent and good awk and sed one liners we will use along with samples and examples in simple shell scripts.
1.To count the number of words in a string which are separated with special charters like ,
 # echo  "apple,mango,orange,goa" | awk -F, '{print NF}'
4
2.How to create and print the continuous variables in a loop after assigning the values to them
i=0
temp="MYTEMP"
echo $temp
while [ $i -le 4 ]
do
let i="i+1"
eval DYNVAR${i}=$temp$i
eval echo "Value in DYNVAR$i is \$DYNVAR$i "
done
3.in the nslookup <IP> output print only Valid hostname of that IP
nc041031:~ # nslookup 9.48.185.207 | awk '/=/ {print $4}'
nc185207.tivlab.austin.ibm.com.
4.in nslookup <Hostname> print only the valid IP of the corresponding host
nc041031:~ # nslookup nc185207.tivlab.austin.ibm.com. |  awk '/Address:/ {print $2}' | grep -v "#"
9.48.185.207
5.Cont ...



Technorati Tags: , , ,




Read more


Oracle RAC Installation FAQs Unix/Linux

Oracle RAC

Oracle RAC stands for Oracle Real Application clusters.
Why do we need RAC ? With Oracle RAC we can enable Single Database to run across cluster of servers. If one fails the other will be able to manage the user requests.It allows multiple nodes in a clustered system to mount and open a single database that resides on shared disk storage. Even if the service fails on one system(node) the database services will be available from other remaining nodes. In a non RAC Database the services will be available only on one system, so if the system fails the DB services will be down (single point of failures).
What is cluster ?
A cluster consists of two or more computers working together to provide
a higher level of availability, reliability, and scalability than can
be obtained by using a single computer.
Hardware requirements for Oracle 11gR2 RAC?
  * A dedicated network interconnect - might be as simple as a fast network connection between nodes; and
  * A shared disk subsystem.
two CPUs, 1GB RAM, two Gigabit Ethernet NICs, a dual channel SCSI host bus adapter (HBA), and eight SCSI disks connected via copper to each host (four disks per channel). The disks were configured as Just a Bunch Of Disks (JBOD)—that is, with no hardware RAID controller.
Ex :
1 cpu
2 GB memory
18 GB local disk with OS 
10 GB local disk for Oracle binaries
3 x 10 GB shared disks for RAC
Software Requiremnts for Oracle 10 g RAC ?
   1. An operating system
   2. Oracle Clusterware
   3. Oracle RAC software
   4. An Oracle Automatic Storage Management (ASM) instance (optional).
What are the supported operating systems and platforms for Oracle RAC ?
    *  Windows Clusters
    * Linux Clusters
    * Unix Clusters like SUN PDB (Parallel DB).
    * IBM z/OS in SYSPLEX
    * HP Serviceguard extension for RAC
Many other platforms and operating systems are supported refer documentation of product.
References :
http://download.oracle.com/docs/cd/B28359_01/install.111/b28264/toc.htm
http://www.oracle.com/technology/software/products/database/index.html
http://www.oracle.com/technology/pub/articles/smiley_rac10g_install.html
http://www.oracle-base.com/articles/11g/OracleDB11gR1RACInstallationOnLinuxUsingNFS.php
http://www.oracle.com/database/rac_home.html
http://www.oracle.com/technology/products/database/clustering/index.html
http://startoracle.com/2007/09/30/so-you-want-to-play-with-oracle-11gs-rac-heres-how/
http://www.orafaq.com/wiki/RAC_FAQ










Read more


merge 2 files line by line and delete duplicate words - shell script , awk

The following shell script main aim is to merge two files line by line and delete the repeated word or duplicate word from each line.

file 1 :
apple goa orange
hello hi how are you
file 2 :
mango goa orange apple
how are you hi hello
Final out put required is :
apple goa orange mango

hello hi how are you
Screen outputs :
nc041031:/opt/krish # cat 1.txt
apple goa orange
hello hi how are you
nc041031:/opt/krish # cat 2.txt
mango goa orange apple
how are you hi hello
nc041031:/opt/krish # cat merge.sh
#!/bin/sh

awk 'NR==FNR{a[FNR]=$0;next} {print a[FNR],$0}' 1.txt 2.txt | tee a.txt
awk '{ while(++i&lt;=NF) printf (!a[$i]++) ? $i FS : ""; i=split("",a); print "" }' a.txt | tee final.txt

nc041031:/opt/krish # ./merge.sh
apple goa orange mango goa orange apple
hello hi how are you  how are you hi hello
apple goa orange mango
hello hi how are you
nc041031:/opt/krish # cat final.txt
apple goa orange mango
hello hi how are you

Read more


df -h -k understanding output du

Many people have asked me how to understand the output of df command.
For all of them i suggest strongly one thing try to use df command as like below first
df -h
tvt2086:/products/WAS64ZLX # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/dasda1           4.2G  3.8G  347M  92% /
udev                   1001M  140K 1001M   1% /dev
/dev/dasdf1           1.3G   14M  1.2G   2% /tools
/dev/mapper/pvols-lhome
                            2.0G   33M  2.0G   2% /home
/dev/mapper/pvols-products
                            6.2G   79M  6.1G   2% /products
/dev/mapper/pvols-ltmp
                            1.0G   33M  992M   4% /tmp

Basically df -h will gives the output in human readable form (-h)
So I will try to explain each column
column 1 : Filesystem
It basically tells how many disk drives are connected and available to the user.In the above case there are 6 drives connected. and they mapped to different folders. Ex : /dev/mapper/pvols-lhome is mounted to directory /home

Column 2 : Size
This basically tells how much capacity the disk is having. Say /dev/mapper/pvols-lhome is mounted to directory /home is of 2 GB capacity

Column 3 : Used
Simple it tells how much is used from the available

Column 4 : Avail
It tells how much is free presently, which is available space

Column 5: Use%
Used disk space in terms of %

Column 6 : Mounted on
This the directory on which the disk is mounted and through which we can use the space available.

we can use df -k Which gives the output in KB format.
Go to any of ur desired location and run the command "df -h ." or "df -k ."
tvt2086:/opt/DCD_Installers # df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/dasda1           4.2G  3.9G  308M  93% /

So it tells the disk details from which current directory is taking space.

"du -sh ." tell the space that was being occupied by current directory.
tvt2086:/opt/DCD_Installers # du -sh .
472M    .
In the above example the directory named "DCD_Installers" is occupying around 472 MB on the disk space.


Read more


Create user in linux with root privileges linux,unix

adduser -u 0 -o -g 0 -G 0,1,2,3,4,6,10 -M root2

adduser  : Command to create a user in linuc
-u           : Set the value of user id to 0 which is generally root user id.
-o            : Set the value of user id to 0 which is generally root user id.
-g           :  Set the initial group number to to 0 generally root user group
-G           : Supplementary groups 0=root, 1=bin, 2= daemon, 3 = sys, 4= adm, 6=disk, 10 = wheel
-M          : 
User home directory will not be created




Read more


No protocol specified Can't open display: cygwin

Displaying Remote Clients

Displaying remote X clients with Cygwin/X is nearly identical to displaying remote X clients with any other X Server. You may use the secure ssh method, or the unsecure telnet method (not recommended).
Secure ssh

On your Windows machine:

1.Make sure you have the openssh package installed.
2.Launch Cygwin/X
3.Run the following in an X terminal:

Username@CygwinHost ~
$ ssh -Y -l username remote_hostname_or_ip_address

4.Enter your password when prompted by ssh.
5.Your ssh session should now show you a shell prompt for your remote machine.
6.You can now launch remote X clients in your ssh session, for example, xterm& will launch an xterm running on your remote host that will display on your Cygwin/X screen.
7.Launch other remote clients in the same manner. I recommend starting the remote clients in the background, by appending & to the command name, so that you don't have to open several ssh sessions.

Unsecure Telnet

On your Windows machine:

1.Make sure you have the inetutils package installed.
2.Launch Cygwin/X
3.In an X terminal type /usr/bin/xhost remote_hostname_or_ip_address
4.In an X terminal type /usr/bin/telnet remote_hostname_or_ip_address. Use the explicit path to ensure that Cygwin's telnet is run instead of Microsoft's telnet; Microsoft's telnet will crash on startup when run from Cygwin/X.
5.Login to your remote machine via your telnet session
6.In your telnet session type, DISPLAY=windows_hostname_or_ip_address:0.0
7.In your telnet session type, export DISPLAY
8.You can now launch remote X clients in your telnet session, for example, xterm& will launch an xterm running on your remote host that will display on your Cygwin/X screen.
9.Launch other remote clients in the same manner; I recommend starting the remote clients in the background, by appending & to the command name, so that you don't have to open several telnet sessions.

Problems and Solutions : 

When there is a problem in DISPLAYING GUIs at client side
Try to check the simple things mentioned below
1. Always the server should allow the X11 forwarding.
   To check this confirm the below (Below example is from AIX 5.3 )

   bash-3.00# cat /usr/local/etc/sshd_config | grep X11
   X11Forwarding yes
   X11DisplayOffset 10
   X11UseLocalhost yes
For linux based systems
nc184120:~ # cat /etc/ssh/sshd_config | grep X11
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
In case the above settings were freshly created please do restart the sshd service like below
    bash-3.00# stopsrc -s sshd;startsrc -s sshd
    0513-044 The sshd Subsystem was requested to stop.
    0513-059 The sshd Subsystem has been started. Subsystem PID is 278682.    
    bash-3.00# lssrc -s sshd
    Subsystem         Group            PID          Status
    sshd             tcpip            278682       active
2. Check your client like putty like tool enabled X11 forwarding and is set to proper tunnel for the running xmanager tool

3. If your xmanager tool is running on your client machine with port 0.0 your putty x11 forwarding should be set to localhost:0.0

Read more


How to read particular line in a file in unix?Shell script or command

How to read particular line in file in Unix. 

We can do that writing a small shell script or Little unix command

Say I have a file named a.txt with some content

bash-3.00$ cat a.txt
Info : === insert : nothing  ON  Sub-Elt Group  ( ~NOC Reporting ) (exists)
Info : === insert : nothing  ON Link SEGP/TZ ( Greenwich Mean Time  CME Permanent ) (exists)
Info : === insert : nothing  ON  Sub-Elt Group  ( ~kb ) (exists)
Info : === insert : INSERT ON Link SEGP/TZ ( Greenwich Mean Time  kb ) (does not exist)
Info : === Update Histo : 0

Now if i want to read the 3rd line from this file we can do the same using 2 ways

bash-3.00$ head -n 3 a.txt | tail -1
Info : === insert : nothing  ON  Sub-Elt Group  ( ~kb ) (exists)

bash-3.00$sed -n '20{;p;q;}' file
Info : === insert : nothing  ON  Sub-Elt Group  ( ~kb ) (exists)

Read more


vmount: Operation not permitted - AIX mount a remote Solaris directory

Mounting a remote Directory on Solaris/Linux to a AIX machine


Solution for mount problems facing on AIX?
Facing Errors like below?

Have you ever tried mounting a shared folder existing on Solaris or Linux machine to a AIX machine ? While doing so most of us will see the below kind of error. So to solve this problem the solution is this post.

bash-3.00#  mount pmgxs2v1:/dbarchive /dbarchive
mount: 1831-008 giving up on:
pmgxs2v1:/dbarchive
vmount: Operation not permitted.

Solution:
bash-3.00# nfso -o nfs_use_reserved_ports=1
Setting nfs_use_reserved_ports to 1
bash-3.00#  mount -n pmgxs2v1 /dbarchive /dbarchive
bash-3.00# cd /dbarchive/
bash-3.00# ls
apache          builds          java            oracle          os              stax            unzipper
browsers        instance        lost+found      oracle-bundles  staf            stax-tnpm

Explanation:
Solaris by default requires any NFS mount to use a so called reserved port below 1024 and AIX 4.3 or above does by default use ports above 1024. 
We can use the nfso command to restrict AIX to the reserved port range as follows:
nfso -o nfs_use_reserved_ports=1

Read more


what are init 0 init 1 init 2 init 3 init 4 init 5 init 6 init s init S init metc

The best solution to know about these init levels is to understand the " man init " command output on Unix.

There are basically 8 runlevels in unix. I will briefly tell some thing about the different init levels and their use. 
Run Level:  At any given time, the system is in one  of  eight  possible run  levels.  A  run level is a software configuration under which only a selected group of processes  exists.  Processes spawned  by init for each of these run levels are defined in /etc/inittab. init can be in one of eight  run  levels,  0-6 and  S  or  s (S and s are identical). The run level changes when a privileged user runs /sbin/init.

init 0 :  Shutdown (goes thru the /etc/rc0.d/* scripts then halts)
init 1  :  Single user mode or emergency mode means no network no multitasking is present in this mode only root has access in this runlevel
init 2  :  No network but multitasking support is present .
init 3  :  Network is present multitasking is present but with out GUI .
init 4  :  It is similar to runlevel 3; It is reserved for other purposes in research.
init 5  :  Network is present multitasking and GUI is present with sound etc.
init 6  :  This runlevel is defined to system restart.
init s   : Tells the init command to enter the maintenance mode. When the
system enters maintenance mode from another run level, only the system console
is used as the terminal.
init S  : Same as init s.
init m : Same as init s and init S.
init M : Same as init s or init S or init m.

We can take it from above that 4 options(S,s,M,m) are synonymous.

Read more


Difference between init 6 and reboot - Unix commands?

Always perform init 6.

init 6 performs reboot of machine in an orderly manner and in a clean way. It changes the runlevel of “svc.startd” daemon to execute rc0 kill scripts.

reboot performs very very quick reboot. It does not execute rc0 kill scripts. It just unmounts filesystem and restarts the system.

While doing a live-upgrade of OS & any patch-updates etc. only init 6 is strongly recommended.

Read more


nfs mount: mount: /release: Device busy error

nfs mount: mount: /release: Device busy
To mount a particular directroy on a remote machine we generally run the following command but ends in the above error
mount -F nfs -o vers=3 9.34.238.37:/release /release
The solutions is to kill the process which is stoping it.

This is was the mopst common error while working of mounting from clients to a remote machine.

mount: device is busy is a common error message when a mount attempt from a UNIX client fails.
Possibilities of this occurance :
If user is in the same directory where he wants to mount a remote directory.
Alternately, the root user (or an ordinary user) is checking a standard mountpoint (e.g. /release) to see
if an external filesystem has been mounted.
They cd to /release, and stay in the directory even though the external filesystem has not yet been mounted.
If the root user is not under the mountpoint and the message remains after trying mount again,
then another user or a process is active under the mountpoint.
A key tool in finding these processes is fuser.
fuser will identify running processes in a filesystem with the process ID number. fuser implementations vary with vendor, so checking the man page is advised. Typically, options include -u for displaying the login name associated with the process, and -k to kill the processes.
Example: #mount ntserver:/c/exports /release mount: device is busy
#fuser -u /release
/release: 951c(root)
So user root is running process 951 under /release , preventing the mounting of the exported filesystem.
The system administrator can then advise root to cd to another directory, or more severely, kill root´s process.

Read more


FTP - windows to unix file upload using FTP

How to upload files from windows to Unix using FTP utility ?

Go to start->run-> type cmd and Hit Enter
in the command prompt go to the location of the file which u want to FTP to remote unix machine.
Say your file location is : C:\Documents and Settings\Kbabu\abc.txt
So go to that directory in command prompt.
Then you want to move your abc.txt file to a unix server with IP 9.180.210.227.
On the server you want to move it to "/opt"

So now at the Windows command prompt give following command 
FTP 9.180.210.227
It asks u for user name and pass word so give those say root/root.
Once you are logged in move to /opt on server
using cd /opt
Then run the following commands one by one 
ha - To know the status of upload (It prints # symbols while upload in-progress)
bi- It transfers files in binary mode.
mput abc.txt - It starts uploading of the file abc.txt once you say "Y" to its confirmation.
Bye - To end the FTP session once transfer of file is completed.

What is ftp?
ftp is a program that allows you to exchange files between your machine, and 
a remote one. You can upload files (send them from your machine to the remote
one), or you can download files (your machine receives them from the remote 
one). FTP is also the name of the protocol the program uses to transfer the 
files (File Transfer Protocol), but in this document, ftp will refer to the 
program. 

Note: There is more than one ftp program (or client), so this file refers to
the command line utility found on most unix/linux systems. The MS-DOS ftp
program will probably be very similar, and even the basics will be applicable
to most GUI (Graphical User Interface) ftp clients. Modern web browsers, and
even some not so modern ones, are able to download files from ftp sites.
  
Why use ftp?

ftp can be used to upload/download any files to any machine running an ftp 
server (or daemon), and on which you have a valid login account, or the server 
has a anonymous account anyone can use. e.g. lots of web sites allow you to 
upload your page with ftp, and lots of programs/files (including many 
distributions of Linux) are available from ftp sites which have anonymous 
accounts. Anonymous accounts are accounts that anyone can use, instead of
entering your user name when prompted, to make use of an anonymous account,
you use the name 'anonymous', and normally you get asked to use your email
address as the account password. Normally an anonymous accout has limited 
privilages, meaning an anonymous user can only access certain parts of the 
site and more often than not, can only download files; they wouldn't be able 
to upload them.

While ftp used to be almost exclusively used for uploading files, it is now
losing ground to scp, which uses ssh to transfer the files, and is 
thus infinitely more secure. The use of scp is beyond the scope of this file,
but there are plans for a file on scp.

Using ftp:

As with most Unix programs, there is more than one way to connect to a remote
ftp site. One way is to start ftp and specify the remote machine (or server) on
the command line. Another way is to start ftp, and then use the open command
inside ftp to open a connection.

Note: Once ftp is running, it has it's own special prompt, just like a unix
shell. This prompt will normally look like this 'ftp>'.

(Please note: A fictional ftp site has been used for security reasons)

cog@pingu:/usr/cog $ ftp ftp.attrition.org
Connected to forced.attrition.org.
220 ProFTPD 1.2.0pre3a Server (forced proftpd service) [forced.attrition.org]
Name (ftp.attrition.org:cog): cog
331 Password required for cog.
Password:
230 User cog logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

or:

cog@pingu:/usr/cog $ ftp
ftp> open ftp.attrition.org
Connected to forced.attrition.org.
220 ProFTPD 1.2.0pre3a Server (forced proftpd service) [forced.attrition.org]
Name (ftp.attrition.org:cog): cog
331 Password required for cog.
Password:
230 User cog logged in.
ftp>

Now you're connected to your ftp site, you need to know how to transfer 
files to (download) and from (upload) your machine to the ftp server.

To upload files from your machine to the server you can use the put and 
mput commands.

put local-file [remote-file] 
Store a local file on the remote machine. If remote-file is 
left unspecified, the local file name is used.
[send can also be used, and is a synonym for put]

mput [local-files]
Expand wildcards in local-files given as arguments and do a 
put for each file.
e.g.:
ftp> put ftp.file.html
local: ftp.file.html remote: ftp.file.html
200 PORT command successful.
150 Opening BINARY mode data connection for ftp.file.html
226 Transfer complete
ftp> put ftp.file.html ftp.html
local: ftp.file.html remote: ftp.html
200 PORT command successful.
150 Opening BINARY mode data connection for ftp.html
226 Transfer complete
ftp> mput */index.*
mput news/index? y
200 PORT command successful.
150 Opening BINARY mode data connection for news/index.
226 Transfer complete.
442 bytes sent in 0.0835 secs (5.2 Kbytes/sec)
mput news/index.html? y
200 PORT command successful.
150 Opening BINARY mode data connection for news/index.html.
226 Transfer complete.
1377 bytes sent in 0.256 secs (5.3 Kbytes/sec)
mput news/index.old.shtml? n
mput linux/index? y
200 PORT command successful.
150 Opening BINARY mode data connection for linux/index.
226 Transfer complete.
1192 bytes sent in 0.156 secs (7.5 Kbytes/sec)
mput linux/index.html? y
200 PORT command successful.
150 Opening BINARY mode data connection for linux/index.html.
226 Transfer complete.
ftp>bye
As the above example shows, when using mput, ftp normally asks you before 
transferring the files. If you're transferring lots of files, this can get 
very tedious, and is time consuming, so I like to start ftp with the -i 
flag. This turns off interactive prompting and transfers the files without
asking you. Once at the ftp> prompt, if you type prompt, you can 
toggle the status of interactive mode.

If, as in the above example, you are transferring files to any directory other
than the current working directory (which can be found using the pwd 
command), then you need to make sure the directory you're transferring files 
to already exists, because ftp will not automatically create it for you.

To create directories you can use the mkdir command just as you would in a
normal Unix shell.

e.g.:

ftp> mkdir /test
257 "/test" - directory successfully created.


Now, to download a file from the remote server to your computer you first 
need to locate the file you want to download. One command you may use to do 
this is ls, which works the same as the unix version of ls, except 
the output is in the format of ls -l. dir can also be used, as 
can mdir. dir is a synonym for ls, and mdir is the same as dir,
except that multiples files can be specified with mdir.

If you need to move around directories on the remote machine you can use
the command cd.

Once you've located the file to download, there are several ways you can get
the file; get, mget, reget, recv and newer.

get remote-file [local-file]
Retrieve the remote file and store it on the local machine. If the
local filename is not specified, it is given the same name as it has
on the remote machine. 

mget is rather like mput; it is the same as get, except that 
wildcards are expanded with mget.

reget also works the same as get, except if the local file already
exists, and the local file is smaller, it assumes that the local file is a
partial download of the remote file and continues the download from the end 
of local file. This is good if the transfer is dropped half way through.

newer is again, the same as get, except the remote file is only got if
it is newer than the already existing local file. This is useful for seeing if
a particular package/file has been updated, and then downloading it if it has.

Read more

Popular Posts

Enter your email address:

Buffs ...

Tags


Powered by WidgetsForFree