Monday, July 31, 2006

all about system info gathering

I had the assignment to gather system info while doing some performance testing with tomcat5.5
here are some of the info that I gotted out wile doing that

find & replace in vi

:%s///g

abt solaris system info

cpuinfo - command vmstat
meminfo - command vm stat

in top u can custermize that to ur preference
f will do the selecting the display columns
h will go to the help mode
W will write to the config file the current settings and many more

also a atsar command at unix
sar - Collect, report, or save system activity information.

Thursday, July 13, 2006

SELinux disable

SELinux is an enhancement to the Linux kernel that implements discretionary access control (DAC) and role-based access control (RBAC).

Disable SELinux by changing the following in /etc/sysconfig/selinux and rebooting the system.
SELINUX=disabled

setenforce 0 this is also be the command that diable on the fly

Wednesday, July 12, 2006

remove the old kernel Ubuntu

Ubuntu always keeps the old kernel when it install a new one, just in case this new one doesn't work well for you.


You can uninstall the old one if you don't use it anymore :
Code:
sudo apt-get remove --purge 2.6.15-23-386*

Doing this will uninstall the packages related to the 2.6.15-23 kernel, like "linux-image-2.6.15-23-386", "linux-restricted-modules-2.6.15-23-386", etc.

TCP MON and Tungsten

How to enable http other than https in the tungsten code
-------------------------------------------------------------------------
change the services.xml protocol to http
if we comment the transport tab then it will expose in all the transport methods

tungstom xml change the debug state to ON

then it should work ..

about thungsten build

Way to get out of trouble


Never do a maven clean build while the link is available to a source location from the targets location that will cleaned

before do any wbm and any other thing do check we whether that extention link exists
if so remove that thing otherwise shot dead

How to create that link

cd target/dist/tungsten-SNAPSHOT/lib/www/
rm -fr extensions/
ln -s ../../../../../modules/www/extensions/

So be alert always

Idea remote debugging

To enable remote debugging in IntelliJ Idea
First create a remote configuration on Idea that you can do remote debugging
The string pattern that will occur will look like this

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

and what we need to do is depending on your executable project wither set the JAVA_OPTS variable to the above
and start the project and then
start the debugger on idea

CINTEC AWARD for the best CSE Project

Received a latter from UOM saying that I will be receiving an award for the best CSE Project , HMM sounds crazy but thats how the life goes on . Let see what they have for me

Wednesday, July 05, 2006

place where the name servers reside

/etc/resolv.conf

cat /etc/resolv.conf to resolve the DNS names

Saturday, June 24, 2006

10 Immutable Laws of Security

The 10 Immutable Laws of Security:


* Law #1: If a bad guy can persuade you to run his program on your computer, it's not your computer anymore

* Law #2: If a bad guy can alter the operating system on your computer, it's not your computer anymore

* Law #3: If a bad guy has unrestricted physical access to your computer, it's not your computer anymore

* Law #4: If you allow a bad guy to upload programs to your website, it's not your website any more

* Law #5: Weak passwords trump strong security

* Law #6: A computer is only as secure as the administrator is trustworthy

* Law #7: Encrypted data is only as secure as the decryption key

* Law #8: An out of date virus scanner is only marginally better than no virus scanner at all

* Law #9: Absolute anonymity isn't practical, in real life or on the Web

* Law #10: Technology is not a panacea

10 Immutable Laws of Security at Microsoft TechNet.

Wednesday, June 21, 2006

Ant bash completion

In the ant/bin folder there is a Perl file called complete-ant-cmd.pl. Check the comment at the top of the file for installation instructions. In my Ubuntu notebook I had to add “complete -C complete-ant-cmd.pl ant build.sh” to my .bashrc file and not “$ complete -C complete-ant-cmd ant build.sh” (no $ and add .pl to the command). Also, not sure why is build.sh needed in all this. Anyhow, after installing this extension command completion for Ant works great. It is a bit slow the very first time you use it but it creates a cache file called .ant-targets-... and then it is much faster.

Sunday, June 04, 2006

note from the hongkong airport

Though this was published late, this was a original blog at that location

Blog Form the Hong Kong International Air

Time : Sri Lanaka 1 45 PM
: Honk Kong 3 45 PM

We 3 (ME , Amila, Sris), finally arrived at the Hong Kong International
Airport. They say that this is the best Airport around. Its one of the
best that you can get. We went shopping but seems all the electronic
equipments are bit expensive than we thought. To refresh the journey all the way up to here we first got in to CX700 and landed in Bankok, Thailand after nearly 3 hours of air time. Lucky I received the window seat there and I got this valuable experience to see the outside when the Airjet take off from the ground. This was my first flight experience and to be at the window at your first flight means that you are very lucky. Saw how the our small world can be seen from
30000 km above and the temperature sometimes around -10 C. But at the Bankok airport we never got the chance to getdown from the plane due to this security reason, thats very unfortunate for us. But leaving bangkok we arrived at Hong Kong after a another 2 and half hour of journey. And we got arroung 4 hour before the the flight to San Fransisco arrives. And then got into the San Fransisco flight and unfortunately the seats are located right in the middle row that we were never saw the outside thought the flight. The flight was almost full and all kinds of pessengers were there. This wes the tedious part of the flight and we almost felt seep 80% of the flight time. The food was served in different menus twise of the flight and Some ware good but some were not that much eatable for me. Finally we arrived at the SF and Ryan was there to meet us. we never got any trouble with the baggages and it was a relief for us.

So that how it goes , first flight completed successfully !

Friday, May 26, 2006

Linux Splash Creation with GIMP

The splash image is the image shown in the background when GRUB is displaying the list of operating systems you can boot. All you need to customize it is the GIMP or Imagemagick and gzip.

You will need to make sure your GRUB supports the splashimage command. I took image from gentoo.org and cut a little for the GRUB background

Creating image (GIMP)

1. Start the GIMP.
2. Click on File->New or type Ctrl+N
3. In the new image dialog, change Width to 640 pixels and Height to 480 pixels. (The image should be of size 640x480 pixels.) Now click OK.
4. Create the image which you would like to be the splash image. It's quite fun to experiment with the various tools of the GIMP!
5. After you have finished creating the image, hit Alt+i or right click on the image and click on Image->Mode->Indexed...
6. In the Indexed Color Conversion dialog that appears, click on the radio button "Generate optimal Palette" and in "# of colors" enter 14. Click OK.(The image should be of only 14 colors)
7. Now right-click on the image and click on File->Save As...Save the file as ImageName.xpm in a directory of your choice.

For some reasons i could not create *.xpm so i save it as *.png and then

convert ImageName.png ImageName.xpm

(convert is a part of media-gfx/imagemagick)

You can save image from this page and convert it skipping image creation hassle


Creating image (Imagemagick)

* You can also pick an image (any type supported by ImageMagick) and execute:

convert -resize 640x480 -colors 14 picture.jpg ImageName.xpm


Installing the Image

gzip ImageName.xpm
mount /boot
mv ImageName.xpm.gz /boot/grub/

* In the /boot/grub/grub.conf you have to point splashimage to newly created image i.e.

File: /boot/grub/grub.conf

# Splash Image
splashimage=(hd0,0)/grub/ImageName.xpm.gz

That's it! When you reboot, you will find your image in the background, with the menu of operating systems etc. in the foreground.

Monday, April 17, 2006

building Axis 2 locally

steps to get the Axis 2 build in GNU/Linux env
----------------------------------------------

download the source from svn repo
$ svn co http://svn.apache.org/repos/asf/webservices/axis2/trunk/java axis2/

get maven installed in the local env
download maven 1.0.2 tar ball and extract that
get the env valiables set MAVEN_HOME and add MAVEN_HOME/bin to the path
u should create the local repo also and then i ll wornt download those jars at the 2 time
$MAVEN_HOME/bin/install_repo.sh $HOME/.maven/repository

check the maven working - source the .bash_profile and then maven

go to the axis2 home and then maven
this will get all the jars nessesary and build axis
thats it :)

Wednesday, April 05, 2006

Apache Portable Runtime and Tomcat

The Apache Portable Runtime is a highly portable library that is at the heart of Apache HTTP Server 2.x.APR has many uses, including access to advanced IO functionality (such as sendfile, epoll and OpenSSL), OS level functionality (random number generation, system status, etc), and native process handling (shared memory, NT pipes and Unix sockets).

APR support requires three main native components to be installed:

  • APR library
  • JNI wrappers for APR used by Tomcat (libtcnative)
  • OpenSSL libraries
wrapper library sources are located in the Tomcat binary bundle.The file is in the bin/tomcat-native.tar.gz . Once the build environment is installed and the source archive is extracted, the wrapper library can be compiled using (from the folder containing the configure script):
./configure && make && make install

First I need to install the APR on my local machine

that I needed to downlod the APR and the APR util in to the same machine and install it in th /usr/local/apr then I compiled the native code of the comcat then that succeed

./configure --with-apr=/usr/local/apr/
make clean && make && make install
-------------------------------------------------------------------------------------------
Check wether the tomcat uses this APR in their process -

then at this java.library.path it search as
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/sandakith/software/jdk1.5.0_06/jre/lib/i386/client:/home/sandakith/software/jdk1.5.0_06/jre/lib/i386:/home/sandakith/software/jdk1.5.0_06/jre/../lib/i386

Then what needed to be done is to include those created libs at /usr/local/apr/lib to the one of the location that it complains that it can not find that

other way is that you can edit the java,library.path - still not done:)
Then that thing in the catalina.out will not be visible and it will optimize the performance using this native libraries

Tuesday, April 04, 2006

All about Acronyms

ASAIK - As Far As I Know
PITA - Pain In The A*

The Microsoft Stress Balls

wso2 had this balls called "stress balls", which we used to play with. These are originally bought from the microsoft itself, by guys who went there. Thilina bought some balls when he arrived in wso2. And there was this "one ball" which was vety flexible and whoever though it feels like to tough it again. Our Apache C team most of the time hold that in their hands when ever they feel any kind of stress. So i got use to this ball and my god one time that ball just explode in my hand and the stuff insode jumped out. O Ow the stuff insode came out and jump in to one of my little friend here who was doing his training. So it was a nightmare to remove all stickey thing from the poor fellow's cloths. It took about 20 mins to wash and dry them. So thasts it, never touch these so called microsoft balls. Never Ever.

One thing is sure.

we came to know how Mr Bill release his stress ;)

Thursday, March 30, 2006

configure a wireless network interface

iwconfig
is the command for the wireless network configeration
This will configure the wireless network as our preferences.
example :
To get this wireless interface activeted on the Fedora Core 4 first had to get the firmware upgraded by adding the firmware patch to the kernal
ipw2200-firmware
This was applied initially
yum update
=====================================
Package Arch Version Repository Size
=====================================
Installing:
ipw2200-firmware noarch 2.4-2 freshrpms 708 k

Transaction Summary
=====================================

And then by executing these commands I can activate my wireless connection
iwconfig eth1 essid WSO2 key 1212121212
dhclient eth1


Connected :)


check the kernal boot up ring params

NAME
dmesg - print or control the kernel ring buffer

SYNOPSIS
dmesg [ -c ] [ -n level ] [ -s bufsize ]

used exaple is needed to know wether the wireless eathernet was started at the kernal booting level.

dmesg | grep ipw

ipw2200: Intel(R) PRO/Wireless 2200/2915 Network Driver, 1.0.0
ipw2200: Copyright(c) 2003-2004 Intel Corporation
ipw2200: Detected Intel PRO/Wireless 2200BG Network Connection
ipw2200: ipw-2.2-boot.fw load failed: Reason -2
ipw2200: Unable to load firmware: 0xFFFFFFFE
ipw2200: failed to register network device
ipw2200: probe of 0000:04:02.0 failed with error -5

Monday, March 27, 2006

extract tar.bz2

tar -jxf archives/Azureus_2.4.0.2_linux.tar.bz2

This will extract the archive to the current folder

-j, -I, --bzip filter the archive through bzip2. Note: -I is deprecated and may get a different meaning in the near future.

Wednesday, March 22, 2006

all about yum

First set your rpm repos on the /etc/yum.conf as

[freshrpms core]
name=Fedora Linux $releasever - $basearch - core
baseurl=http://ayo.freshrpms.net/fedora/linux/$releasever/$basearch/core
#gpgcheck=1

[freshrpms updates]
name=Fedora Linux $releasever - $basearch - updates
baseurl=http://ayo.freshrpms.net/fedora/linux/$releasever/$basearch/updates
#gpgcheck=1

[freshrpms extras]
name=Fedora Linux $releasever - $basearch - extras
baseurl=http://ayo.freshrpms.net/fedora/linux/$releasever/$basearch/extras
#gpgcheck=1

[freshrpms]
name=Fedora Linux $releasever - $basearch - freshrpms
baseurl=http://ayo.freshrpms.net/fedora/linux/$releasever/$basearch/freshrpms
#gpgcheck=1


Then import the key from the Fresh rpm site otherwise you wornt get the yum succesfully working on your thing.
su -
rpm --import http://ftp.freshrpms.net/pub/freshrpms/RPM-GPG-KEY

The serch a thing
yum search

The install a thing using yum
yum install

To erase a thing
yum erase

Thursday, March 02, 2006

ftp made easy

[lsandakith@eng1 Desktop]$ ftp
ftp> open ralph
Connected to ralph.sl.valista.com.
220 ralph FTP server (SunOS 5.8) ready.
500 'AUTH GSSAPI': command not understood.
500 'AUTH KERBEROS_V4': command not understood.
KERBEROS_V4 rejected as an authentication type
Name (ralph:lsandakith): oracle
331 Password required for oracle.
Password:
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> put GemplusIssue_DaemonLoop_030306.tar.gz
local: GemplusIssue_DaemonLoop_030306.tar.gz remote: GemplusIssue_DaemonLoop_030306.tar.gz
227 Entering Passive Mode (172,16,80,11,149,215)
150 Binary data connection for GemplusIssue_DaemonLoop_030306.tar.gz (10.30.1.237,61450).
226 Transfer complete.
15419 bytes sent in 0.13 seconds (1.1e+02 Kbytes/s)
ftp>

Wednesday, March 01, 2006

how to use tomcat server manager

It would be quite unsafe to ship Tomcat with default settings that allowed anyone on the Internet to execute the Manager application on your server. Therefore, the Manager application is shipped with the requirement that anyone who attempts to use it must authenticate themselves, using a username and password that have the role manager associated with them. Further, there is no username in the default users file ($CATALINA_HOME/conf/tomcat-users.xml) that is assigned this role. Therefore, access to the Manager application is completely disabled by default.

To enable access to the Manager web application, you must either create a new username/password combination and associate the role name manager with it, or add the manager role to some existing username/password combination. Exactly where this is done depends on which Realm implementation you are using:

* MemoryRealm - If you have not customized your $CATALINA_HOME/conf/server.xml to select a different one, Tomcat 5 defaults to an XML-format file stored at $CATALINA_HOME/conf/tomcat-users.xml, which can be edited with any text editor. This file contains an XML for each individual user, which might look something like this:
which defines the username and password used by this individual to log on, and the role names he or she is associated with. You can add the manager role to the comma-delimited roles attribute for one or more existing users, and/or create new users with that assigned role.

Search for a class file inside a jar

This is the power of shell scripting ---->
find -name '*.jar' -exec grep DiscountProgram {} \; -print

Tuesday, February 28, 2006

changing the owner of files dirs

chown file/dir user:group -R

-R for recursive to all the files and subdirs in that perticular dir

Thursday, February 23, 2006

The whole Idea of Blogging

I just found an article on blogging.
The only one line that cought my eye was,

tail -f /dev/mind > blog

Thats explins everything, Right :)
Actually I thought the whole article was useless with out that one line.

Finding Linux version

cat /etc/redhat-release

or use following commands:
uname -a
uname -X

Restarting solaris machine

On solaris, dont just type reboot. That will make the machine hang in init 1 (single user mode)
instead, type the following:

>shutdown -y -g0 -i6

Using NFS on Solaris

NFS on solaris
To start the NFS services:
$ su -
$ cd /usr/lib/nfs
$ ./mountd
$ ./nfsd

# mountd: RPC server that answers requests for NFS access information and file system mount requests
# nfsd: The daemon that handles client file system requests

Sharing A File System

The following example will share a file system /software so that others may be able to mount it:

# share /software

If I want to check all file systems being shared from my system:

# share
- /software rw ""

How to NFS A File System

Now, from another machine, I want to NFS the file system that is being shared above:

# mount -F nfs alex:/software /mnt/software

Using SCP to copy files

# scp source target

# scp joeshmoe@miles.shadlen.org:matlab/mfile.m matlab/

# scp example.m joeshmoe@miles.shadlen.org:unfinished/silly.m
------------------------------------------------------------------------------------------------------------------------
Copy directory ``/usr/local/share'' and its contents from your Linux file space to your own workstation:

#scp -r username@hostname.sl.valista.com:/usr/local/share .

(``.'' means copy the files to the current directory on your workstation. A new directory ``share'' will be created there containing copies of the files and directories in the server's ``share'').

Finging Files with Find

# find path operators

where path is the directory in which find will begin to search and operators tell find which files you are interested in.

Example:

To find a file with specific name,

# find . –name “*ab*” –print

Where the starting point is current directory. (This will find all files under the current directory that has “ab” somewhere in the name.)

find can be used to find files using a lot of other attributes:

# find . -mtime +2 -print
finds files that have been modified for more than 2 days.

# find . -atime -5 -print
finds files that have been accessed for less than 5 days.

# find . –type f –print
Find the file by type
f- Plain file
l- symbolic link
d- directory

# find . –size 1234c –print
finds the file with exactly 1234 bytes

# find . –size +10000c –size -32000c –print
finds the all files in current directory that are grater than 10000bytes, but less than 32000bytes.

# find . –perm -100 -print
find the files with permission 100 (--x------)
---------------------------------------------------------------------------------------------------------------------------
Another useful command to use with this is -exec

find . -name *.jar -exec ls -l {} \;

Find all the jars under the current directory and execute ls -l on each

All about compression on Unix/Linux

Often you would want to compress or uncompress files when you want to move it from one machine to another. This reduces the time it takes to copy the file over the network. I have added below most of the compression methods I am familiar with and will be adding more as I learn of them...please feel free to add in your own replies!

Using tar files

Tar files dont actually compress anything. They just bundle up files into one Tape ARchive. Which is why you generally see that tar files also zipped with gzip.

To create a tar file:
#tar -cvf .tar
Note: The extension needs to be specified. The target can be a wildcard or a directory.

To unroll a tar file:
#tar -xvf
Note: You might want to run tar with the -tvf switch to see what the file contains before extracting.

To create a zipped tar file (using gzip):
#tar -zcvf .tar.gz

To untar and to uncompress a tar file in one command (valid for gzipped files):
#tar -zxvf
----------------------------------------------------------------------------------------------------------------------
Oh and by the way, to confirm that the file you are copying is correctly copied to the target machine, u can you the "sum" command which prints out the checksum for the file.

#sum

The checksum should be identical with the source machine.

PS: If you are using Windows, I dont think you will have a checksum utility (??). I would suggest you install cygwin which provides windows versions of all the common Unix commands.

\\fileserver\public\software\windows\X-Servers\setup.exe


or

http://www.cygwin.com/

Mounting Remote File Share

On Linux you can mount remote file share under your file system and then you can access them as they are in your local file system.

File can be shared using different types (NFS, Samba etc.)

Before you mount any remote file share you should complete the following steps.

1) Create a mount point on your local file system.
eg:
#mkdir /mnt/fileshare
2) Find out the remote file share type ( NFS, SMB etc)
3) Remote file share name (Server name and share name)
eg:
Server name: public.valista.com ShareName: public Type:samba

Then you can use the mount command to mount the remote file share.

# mount -t filesystemtype -o options

For more information about mount command
# man mount

Now if you would like to mount public.valista.com/public under /mnt/fileshare

#mount //public.valista.com/public /mnt/fileshare -t smbfs -o defaults,umask=0022

If you want to this mount point permanent edit the file /etc/fstab adding the following line

//public.valista.com/public /mnt/fileshare smbfs defaults,umask=0022 0 0

Now if you type
#ls -l /mnt/fileshare

You can see the shared files on public.valista.com/public file share

******************************************************
If you would like to browse remote samba share on your file browser. Type the command

#nautilus smb://fileserver.valista.com/public

Using jdk1.3.1_xx in fedora core 4

to make the same production environment in the client side we may need to setup the environment similar to legacy systems that our clients have.
In the case of Using jdk1.3.1_xx in fedora core 4 it gives the issue of

Error occurred during initialization of VM Unable to load native library: /usr/local/jre1.3.1_06/lib/i386/libjava.so: symbol __libc_wait, version GLIBC_2.0 not defined in file libc.so.6 with link time referenceE


This arise because I tried to use versions available in the public server of 1.3.1_XX with fedora.

Solution :
jdk 1.3.1_XX is not recommended other than UNIX versions RH 7.2 or below kernel versions
The fixed rpm one is available on the sun Java site that is 1.3.1_16
This version of the jdk(The rpm) OK with the fedora core.

Setting up Multiple X Sessions on a Single Monitor

If you need to run multiple X servers concurrently and let us switch back and forth between them as required. So, Control-Alt-F7 is 1st X server and Control-Alt-F8 is 2nd so on.
First we have to test our second session.

Testing the Second Session

The first step is to test the second session manually. Simply log to a console window (Control-Alt-F1 for example) and type the following:

startx -- :1 vt8

This will start an X server on virtual terminal 8 and the DISPLAY environment variable will be :1.0 instead of :0.0.

The :1 is the display name and vt8 is the virtual terminal number. Since vt7 is the default terminal for X, and I running consoles on vt1-vt6, I chose vt8 for the second X session. Be sure that it isn't already being used for a console. Console VTs are started by /etc/inittab.

Making the Change Automatic

Typically, X is started when init changes to runlevel 5. If you look at /etc/inittab, you will see a record that looks like:

x:5:once:/etc/X11/prefdm -nodaemon

This in turn will run the appropriate display manager. By default, this is gdm or kdm and the choice is dependent on the value of the DESKTOP variable defined in /etc/sysconfig/desktop. Even though desktop is "GNOME", you need to use the xdm display manager since GNOME doesn't support multiple displays. You can override this default by having the following two records in /etc/sysconfig/desktop:

DESKTOP="GNOME"
DISPLAYMANAGER="XDM"

Now, when you switch to runlevel 5 (which is the default at boot time), you will be using the XDM window manager instead of kdm or gdm. The next step is configure xdm to start the second session. This is done by simply adding another record to the /etc/X11/xdm/Xservers file:

:0 local /usr/X11R6/bin/X :0 vt7
:1 local /usr/X11R6/bin/X :1 vt8


Verifying Your Changes

You don't need to reboot for this to take effect. Simply log out of your X session, switch to a lower run-level, and then switch back to run-level 5:

* init 3
* init 5


Then you will see two X sessions when you press
Control-Alt-F7 is 1st X server and Control-Alt-F8 is 2nd
Frist we have to test our second session.

Enabling Java Plugin for FireFox

If you come across an issue where left panel of weblogic console is not show here is the solution.

Assumption
You need to install JDK in you machine and java home is reffered as $JAVA_HOME

Type the following commands
cd ~/
cd .mozilla/plugin Note: If the plugin directory is not available create it manually
ln -s $JAVA_HOME/jre/plugin/i386/ns610-gcc32/libjavaplugin_oji.so

Now restart the browser!

Changing file permission the easy way

You change a file's permissions using the Unix command "chmod" (for "change mode").
The chmod command supports a handy shortcut for setting permissions: You express the permissions
you want as a three-digit number, like "644" or "755", with the first digit giving
the owner's permissions, the second digit giving the group permissions, and the last digit
giving the "everybody else" permissions. The numbers themselves are arrived at by simple addition,
using the following formula:

4 = read permission
2 = write permission
1 = execute permission

SNMP trap monitoring and trap generating

Find where the snmptrapd is installed. ( I found it is /usr/sbin)
Give the following command as the su -
snmptrapd -f -Le
If a SNMP trap is generated you will see it in the console.

To generate a SNMP trap manually ( With this you can verify that snmptrapd is working!!)

There is a handy tool (Look in http://www.ncomtech.com/software/TrapGen) to generate traps. The trapgen for linux is available at smb://fileserver/public/software/linux.
Extract the tool and give the command ./trapgen -f input.txt or ./trapgen -d as the su -
This would generate a SNMP trap and if the snmprapd is running u can see the trap logged there.

tar -xvf does not extract all directories ( solaris )

Sometimes the tar -xvf does not extract all the directories in the archive, and gives the directory checksome error, there is a workaround for that.

Uncompress the .tar.gz in your local machine(linux or windows) and make a .zip archive of it.
scp the .zip archive to solaris machine and uncompress using the following command.
jar -xvf

This will untar all the directories.
------------------------------------------------------------------------------------------------------------------------------------
The reason why tar didn't work is because the standard Solaris /usr/bin/tar can't unpack files which contain very long directory paths. (Can't remember what the limit is).

The permanent way to fix this is to get the GNU tar package for the correct Solaris version and hardware architechture (SPARC or x86) from http://www.sunfreeware.com (pick your nearest mirror).

You'll need to use pkgadd to install the package:

As root:

# pkgadd -d

Finding the disk used space

Here's a handy command sequence which you can run anywhere, anytime, so see which directories contain the most amount of data. It's a really useful way to focus your attention on the biggest users of disk space. It's best run as root, so you have access to everyone's files:

# du -k / | sort -rn | less

* 'du -k / ' means "Show me disk usage (in kilobytes) for all directories mounted on /"
* 'sort -rn' means "Sort in reverse numeric order (largest first)"
* 'less' is a handy favourite pager.

This will give you a list of directory sizes followed by the directory name. The top ones are where you should focus your attention.

Starting up Oracle DB

Often when your DB machine reboots, the DB might not be in an open state and would need to be restarted. This is a very common set of commands that we often forget.
I have added it below for convenience:

>sqlplus /nolog
>connect /as sysdba
>startup

Then at the command prompt:

>lsnrctl start

That should get the DB up and running.

To make sure that your TNS is working from the machine that you want to establish connection, type the following:

>tnsping

it should return OK.

If you want to check as to what the existing TNS names on your machine, look in the following file:

$ORACLE_HOME/network/admin/tnsnames.ora

How to drop a deleted datafile from Oracle

The symptom error is :
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: 'E:\ORACLE\ORADATA\CESCATI\SYSTEM01.DBF'

a. Execute "connect internal". If it complains about the ORACLE_SID not being set, then check to make sure that the ORACLE_SID environment variable is properly set. With the default setup, you could issue a command like "setenv ORACLE_SID eqs" from the csh prompt. On Windows 2000 use the environment variable modification tool under Control Panel -> System. If you have this problem on , Win2000 you should probably redo the entire Oracle installation. On UNIX you will have to run as the account that own oracle.

b. Execute "shutdown abort" to make sure the database is shutdown.

c. Execute "startup nomount". (This is the most primitive way of starting the database.)

d. Execute "alter database mount" (This should mount the database, and server manager should reply with the string "Statement Processed")

e. Execute "alter database datafile offline drop" where is the name of the operating system file that you have deleted or otherwise butchered. It should be surrounded by single quotes ( ' ).

f. If the last statement executed, you should be in the clear. Execute "shutdown immediate" to shutdown the database.

g. Exit server manager.

NOTE: To find out the datafile name , use the v$datafile view (Name column)

Time/Date in oracle

To work with timestamps in oracle, use the to_timestamp function.

A time stamp looks like this : 07-NOV-05 03:50:23.553750

delete from sessn where last_used < to_timestamp('14-Dec-04');

Locating unicode chars in DB

This is an interesting one from a customer:

If you suspect that a field in an Oracle DB is having wierd unicode non-english chars, how do you confirm it? Sometimes these chars will be translated as valid English chars and cause all the more confusion. The answer is to use the asciistr function. This function returns all the chars as ascii strings...and unicode chars as escaped hexadecimal values.

E.g: select dep_id, asciistr(ALIAS) from gp_dependent where asciistr(ALIAS) like '%\%';

Its quite useful, note the opposite of the above is the unistr function. This one takes hexadecimal values in a string an converts into a Unicode text string.

Redirecting SQLplus output to text file

You could try spooling the output, but here is an easier option:

test.sql should contain your sql statements.

sqlplus -s scott/tiger <> test.lst
@test
exit
STOP

Creating tablespaces using sqlplus

Create regular tablespaces:

CREATE TABLESPACE sj_data
DATAFILE '/u01/app/oracle/oradata/street/sj_data.dbf'
SIZE 10M reuse
AUTOEXTEND ON NEXT 10M

CREATE TABLESPACE sj_default
DATAFILE '/u01/app/oracle/oradata/street/sj_default.dbf'
SIZE 10M reuse
AUTOEXTEND ON NEXT 10M

CREATE TABLESPACE sj_index
DATAFILE '/u01/app/oracle/oradata/street/sj_index.dbf'
SIZE 10M reuse
AUTOEXTEND ON NEXT 10M

Finally, create the TEMPORARY tablespace:

create temporary tablespace sj_temp
tempfile '/u01/app/oracle/oradata/street/sj_temp.dbf'
size 10M reuse
AUTOEXTEND ON NEXT 10M

Monday, February 13, 2006

how to add a user (UNIX) and use as a ctl+alt+F9(X:1)

su -
adduser robocop
passwd robocop

login :robocop
passwd : robocop

export DISPLAY=:1
X :1 &
gnome-session &