Thursday, October 18, 2012

Change default Java version in Linux (Ubuntu)

I have decide to install jdk1.6.0_24 to my Ubuntu server 10.04 LTS and I want to make this as default java in my servere.

Note: if you laready have version you want to make default simple run the step 4 .

  1. Installed above jdk using jdk-6u24-linux-x64.bin in preferred directory
    in my case  : ‘/usr/lib/jvm’
  2. Once you installed I got following directory installed  ‘/usr/lib/jvm/jdk1.6.0_24’
  3. Now run following command :
    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_24/jre/bin/java" 1
  4. Now time to select which java version you prefer , simple run and select the version
    sudo update-alternatives --config java
      eg :
       Selection    Path                                      Priority   Status
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/jdk1.6.0_24/jre/bin/java      1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
That’s it your default java now set to target version.

  5. Same time you can change $JAVA_HOME and path variable to reflect changes . I prefer global change  
       so I edit /etc/profile and append
       export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_24
       export PATH=$PATH:$JAVA_HOME/bin

That’s it your server now refer to preferred java version .

Wednesday, October 17, 2012

Open Port scaning for linux(Ubuntu)

If you want ever want to find the ports that are open in a target server or network you may use
utility call `nmap` .
eg :
 in Ubuntu       1. Install the nmpa using -- > sudo apt-get install nmap
                       2.port scan for target ip  -- >  nmap -v -sT

you may get an output like below . Please use `nmap `Manual page to find more options

Starting Nmap 5.21 ( ) at 2012-10-17 18:45 PGT
Initiating Ping Scan at 18:45
Scanning [2 ports]
Completed Ping Scan at 18:45, 0.01s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 18:45
Completed Parallel DNS resolution of 1 host. at 18:45, 0.06s elapsed
Initiating Connect Scan at 18:45
Scanning [1000 ports]
Discovered open port 80/tcp on
Discovered open port 8080/tcp on
Discovered open port 3306/tcp on
Discovered open port 445/tcp on
Discovered open port 22/tcp on
Discovered open port 21/tcp on
Discovered open port 139/tcp on
Discovered open port 8081/tcp on
Discovered open port 8090/tcp on
Completed Connect Scan at 18:45, 0.02s elapsed (1000 total ports)
Nmap scan report for
Host is up (0.00094s latency).
Not shown: 991 closed ports
21/tcp   open  ftp
22/tcp   open  ssh
80/tcp   open  http
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3306/tcp open  mysql
8080/tcp open  http-proxy
8081/tcp open  blackice-icecap
8090/tcp open  unknown

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.13 seconds