Senin, 21 Desember 2009

Install Hamachi on Ubuntu 9.04

  1. To being we must install the ‘tun’ module to enable IP Tunneling support for the Linux kernel. Most do not have this setup by default.
  2. $ sudo modprobe tun
  3. Open the modules file and add ‘tun’ to the list
  4. $ sudo nano /etc/modules
  5. Your file should look similar to the example below.
  6. # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with "#" are ignored.

    lp
    rtc
    tun
  7. Save the file and exit out of nano (Ctrl-O to save & Ctrl-X to exit), lets move on and verify that a tunneling node has been created. (*If you have compiled your own kernel you likely need to recompile it with IP Tunneling support if you receive an error with modprobe. This is not covered in this guide. And if you are unsure, you most likely did not compile yourself and you would definitely remember doing so.)
  8. $ ls /dev/net/tun
  9. You should recieve a response like the example below
  10. /dev/net/tun
  11. If you received something along the lines of “No Such File or Directory” you may need to manually create the node in step 6. If you received the same response as I did, jump to step 7.
    $ sudo mkdir /dev/net
    $ sudo mknod /dev/net/tun c 10 200

    Jump back to Step 4 and you should now receive the correct response.

  12. With our IP Tunnel node created, it is time to install Hamachi itself. First download the latest version. As of writing this guide, the latest version is 0.9.9.9-20
  13. $ wget http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz

    Expected output below

    --2009-07-31 20:28:25--  http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz
    Resolving files.hamachi.cc... 69.25.20.50
    Connecting to files.hamachi.cc|69.25.20.50|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 344866 (337K) [text/plain]
    Saving to: `hamachi-0.9.9.9-20-lnx.tar.gz'

    100%[====================================================================>] 344,866 448K/s in 0.8s

    2009-07-31 20:28:26 (448 KB/s) - `hamachi-0.9.9.9-20-lnx.tar.gz' saved [344866/344866]
  14. Extract our newly downloaded archive
  15. $ tar zxvf hamachi-0.9.9.9-20-lnx.tar.gz

    Expected output below

    hamachi-0.9.9.9-20-lnx/
    hamachi-0.9.9.9-20-lnx/Makefile
    hamachi-0.9.9.9-20-lnx/LICENSE
    hamachi-0.9.9.9-20-lnx/README
    hamachi-0.9.9.9-20-lnx/LICENSE.tuncfg
    hamachi-0.9.9.9-20-lnx/LICENSE.openssh
    hamachi-0.9.9.9-20-lnx/LICENSE.openssl
    hamachi-0.9.9.9-20-lnx/hamachi
    hamachi-0.9.9.9-20-lnx/tuncfg/
    hamachi-0.9.9.9-20-lnx/tuncfg/Makefile
    hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg.c
    hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg
    hamachi-0.9.9.9-20-lnx/CHANGES
  16. Navigate into the extracted directory
  17. $ cd hamachi-0.9.9.9-20-lnx/
  18. Start the installation
  19. $ sudo make install

    Expected output below

    Copying hamachi into /usr/bin ..
    Creating hamachi-init symlink ..
    Compiling tuncfg ..
    Copying tuncfg into /sbin ..

    Hamachi is installed. See README for what to do next.
  20. Run the tunnel
  21. $ sudo tuncfg
  22. This should complete the install, we will now configure the user permission in order for it to run correctly. Create a ‘hamachi’ user group
  23. $ sudo groupadd hamachi
  24. Add youself as a user to the ‘hamachi’ group. Be sure to replace your user name where appropriate.
  25. $ sudo gpasswd -a YOURUSERNAME hamachi
  26. Add the root user to the ‘hamachi’ group
  27. $ sudo gpasswd -a root hamachi
  28. Set the correct permissions for the tuncfg socket
  29. $ sudo chmod 760 /var/run/tuncfg.sock
  30. Change the ownership of the socket file
  31. $ sudo chgrp hamachi /var/run/tuncfg.sock
  32. That should do it for the permissions, Now onto setting Hamachi up & configuring it to start as a system service.
  33. $ sudo hamachi-init -c /etc/hamachi

    Expected output

    Initializing Hamachi configuration (/etc/hamachi). Please wait ..

    generating 2048-bit RSA keypair .. ok
    making /etc/hamachi directory .. ok
    saving /etc/hamachi/client.pub .. ok
    saving /etc/hamachi/client.pri .. ok
    saving /etc/hamachi/state .. ok

    Authentication information has been created. Hamachi can now be started with
    'hamachi start' command and then brought online with 'hamachi login'.
  34. Start hamachi
  35. $ sudo hamachi -c /etc/hamachi start

    Expected output

    Starting Hamachi hamachi-lnx-0.9.9.9-20 .. ok
  36. Set your computer’s nickname
  37. $ sudo hamachi -c /etc/hamachi set-nick "COMPUTERNICKNAME"
  38. Login to the Hamachi network
  39. $ sudo hamachi -c /etc/hamachi login
  40. To join an existing network (optional) “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password
  41. $ sudo hamachi -c /etc/hamachi join NETWORKNAME PASSKEY
  42. To create a new network (optional) “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password
  43. $ sudo hamachi -c /etc/hamachi create NETWORKNAME PASSKEY
  44. If you joined an existing network you must tell hamachi to then “go-online”. Be sure to replace NETWORKNAME with your relevant network name.
  45. $ sudo hamachi -c /etc/hamachi go-online NETWORKNAME
  46. Check your hamachi status to verify everything is as it should be
  47. $ sudo hamachi -c /etc/hamachi

    Expected output

    Hamachi, a zero-config virtual private networking utility, ver 0.9.9.9-20

    version : hamachi-lnx-0.9.9.9-20
    pid : 5472
    status : logged in
    nickname : JauntyVM

Ubuntu Linux Install Sun Java Development Kit ( JDK ) and Java Runtime Environment ( JRE )

Q. How do I install Sun Java Development Kit (JDK) and Java Runtime Environment (JRE) under Ubuntu Linux? It appears that there are multiple JRE installed by default under Ubuntu. How do I select and use Sun JRE only? Can you explain steps required to set the environment to run java programs or apps?

A. Ubuntu Linux 7.10 has following packages from Sun:
=> sun-java6-bin : Sun Java Runtime Environment (JRE) 6

=> sun-java6-demo : Sun Java Development Kit (JDK) 6 demos

=> sun-java6-jdk : Sun Java Development Kit (JDK) 6

=> sun-java6-jre : Sun Java Runtime Environment (JRE) 6

Install Sun Java 6

To install proprietary Java, you must have the Multiverse repository enabled. Click on System > Administration > Software Source > Select Multisource > Close
Adding the Universe and Multiverse Repositories

Open a shell prompt (terminal) and type the following to install JDK and JRE:


$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

Setup the default Java version

Ubuntu Linux comes with update-java-alternatives utility to updates all alternatives belonging to one runtime or development kit for the Java language. To select, Sun's JVM as provided in Ubuntu 7.10, enter:


$ sudo update-java-alternatives -s java-6-sun

You also need to edit a file called /etc/jvm. This file defines the default system JVM search order. Each JVM should list their JAVA_HOME compatible directory in this file. The default system JVM is the first one available from top to bottom. Open /etc/jvm

$ sudo vi /etc/jvm

Make sure /usr/lib/jvm/java-6-sun is added to the top of JVM list

/usr/lib/jvm/java-6-sun

At the end your file should read as follows:
/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-gcj
/usr/lib/jvm/ia32-java-1.5.0-sun
/usr/lib/jvm/java-1.5.0-sun
/usr


Save and close the file.

Setup the environment variable

You also need to setup JAVA_HOME and PATH variable. Open your $HOME/.bash_profile or /etc/profile (system wide) configuration. Open your .bash_profile file:


$ vi $HOME/.bash_profile

Append following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

Save and close the file.

Test your new JDK

Type the following command to display version:


$ java -version


Output:

java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)

Try HelloWorld.java - first java program

$ vi HelloWorld.java


Append code:

public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }

Save and close the file. Compile HelloWorld.java and execute program by typing following two instructions:
$ javac HelloWorld.java
$ java HelloWorld

Output:

Hello, World!