Monday, September 15, 2008

How to Change Runlevels (LINUX GURU)

Many people get confused when trying to boot in to a runlevel other than runlevel 5, for example runlevel 3, disabiling the GUI front end with which most users are familiar. Hopefully this howto will help answer the questions "How do I disable X" or "How do I boot without X" or even "How do I get to single user mode.

Runlevels

0 - halt (Do NOT set initdefault to this)
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused or Admin
5 - X11
6 - reboot (Do NOT set initdefault to this)


How to set the default run level 5

Open /etc/inittab to change your runlevel

On about line 18 you will see a line like the one shown below.
id:3initdefault:

change it to 5 as below

id:5:initdefault:
Save file and exit

Wednesday, July 30, 2008

Remove an element in a JavaScript Array

A Easy Way to remove element from array in a javascript.

e.g. var arr = {"one":"Ram","two":"Mangesh","three":"Vishnu"};

now we have remove the element whose value is "Mangesh" and key is "two"

delete arr['two'];

Thursday, June 26, 2008

Install Apache Tomcat 5.5.26 on Fedora Core 6

Install the JDK on Fedora


1] Download tomcat Binary Distribution from http://tomcat.apache.org/download-55.cgi

2] Unzip and copy it /usr/local/

You will see directory structure similar like this

/usr/local/apache-tomcat-5.5.26

3] Now to set the environment variable CATALINA_HOME, JAVA_HOME and add it also in PATH

Open file “/root/.bashrc”

Append following three line.

export JAVA_HOME="/usr/java/jdk1.6.0_06"

export PATH=$PATH:/usr/java/jdk1.6.0_06/bin

export CATALINA_HOME=/usr/local/apache-tomcat-5.5.26

4] Now Start the Tomcat

/usr/local/apache-tomcat-5.5.26/bin/catlina.sh start

5 ] run the following URL in Browser.

http://localhost:8080/


Tuesday, June 24, 2008

Install the SUN JDK 1.6.0_06 on Fedora Core 6

1] Download the SUN JDK 1.6. From the following link. Compatible for fedora

http://java.sun.com/javase/downloads/index.jsp

You will get binary something name as “jdk-6u6-linux-i586.bin”

3. Now change the permission of the downloaded file to 777 like this:

chmod 0777 jdk-6u6-linux-i586.bin

4. Then run it:


./jdk-6u6-linux-i586.bin

You will need to type yes to indicate your acceptance to their agreement and the installation will complete on its own. Unfortunately you are not yet done. Type java -version on the command line and you will see that it still points to the crappy old JVM from gcj (GNU compiler for JAVA).

This will extract binary and install the jdk 1.6.0_06

Now you will see something like directory structure

/usr/java/jdk1.6.0_06/

5. Now you need to find the actual location of your JDK installation and indicate to Fedora to accept your choice.

Type the following:
updatedb;locate javac |grep bin

You will see an entry like this:
/usr/java/jdk1.6.0_06/bin/javac

Here /usr/java/jdk1.6.0_06 is the actual JAVA_HOME for your machine. Note this as you will need it to run the future commands.

Now you need to run the alternatives command to instruct Fedora to recognize Sun’s JVM.
alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_06/bin/java 100
alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_06/bin/jar 100
alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_06/bin/javac 100

You can do this for other Java executables too, should you need them, following the same pattern.

Finally you should configure alternative to use Sun’s JVM as the default JVM. To do this type:

/usr/sbin/alternatives --config java

This will present you with at least 2 options. Choose the one for Sun’s JVM.

Similar way you can do that for jar and javac command

/usr/sbin/alternatives --config jar

/usr/sbin/alternatives --config javac

Now you are done configuring Fedora for the most part. Type java -version and you should see something like this:

java version "1.6.0_06"

Java(TM) SE Runtime Environment (build 1.6.0_06-b02)

Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

Note: This works for most part, except Tomcat.The default installation of Tomcat has been hardwired to use GCJ (GNU Compiler for JAVA).