3/11/13

25 Iptables-rules



1. Delete Existing Rules

Before you start building new set of rules, you might want to clean-up all the default rules, and existing rules. Use the iptables flush command as shown below to do this.
iptables -F
(or)
iptables --flush

2. Set Default Chain Policies

The default chain policy is ACCEPT. Change this to DROP for all INPUT, FORWARD, and OUTPUT chains as shown below.
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
 
When you make both INPUT, and OUTPUT chain’s default policy as DROP, for every firewall rule requirement you have, you should define two rules. i.e one for incoming and one for outgoing.

In all our examples below, we have two rules for each scenario, as we’ve set DROP as default policy for both INPUT and OUTPUT chain.
If you trust your internal users, you can omit the last line above. i.e Do not DROP all outgoing packets by default. In that case, for every firewall rule requirement you have, you just have to define only one rule. i.e define rule only for incoming, as the outgoing is ACCEPT for all packets.
Note: If you don’t know what a chain means, you should first familiarize yourself with the IPTables fundamentals.

3. Block a Specific ip-address

Before we proceed further will other examples, if you want to block a specific ip-address, you should do that first as shown below. Change the “x.x.x.x” in the following example to the specific ip-address that you like to block.
BLOCK_THIS_IP="x.x.x.x"
iptables -A INPUT -s "$BLOCK_THIS_IP" -j DROP
This is helpful when you find some strange activities from a specific ip-address in your log files, and you want to temporarily block that ip-address while you do further research.
You can also use one of the following variations, which blocks only TCP traffic on eth0 connection for this ip-address.
iptables -A INPUT -i eth0 -s "$BLOCK_THIS_IP" -j DROP
iptables -A INPUT -i eth0 -p tcp -s "$BLOCK_THIS_IP" -j DROP

4. Allow ALL Incoming SSH

The following rules allow ALL incoming ssh connections on eth0 interface.
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
Note: If you like to understand exactly what each and every one of the arguments means, you should read How to Add IPTables Firewall Rules

5. Allow Incoming SSH only from a Sepcific Network

The following rules allow incoming ssh connections only from 192.168.100.X network.
iptables -A INPUT -i eth0 -p tcp -s 192.168.100.0/24 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
In the above example, instead of /24, you can also use the full subnet mask. i.e “192.168.100.0/255.255.255.0″.

6. Allow Incoming HTTP and HTTPS

The following rules allow all incoming web traffic. i.e HTTP traffic to port 80.
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
The following rules allow all incoming secure web traffic. i.e HTTPS traffic to port 443.
iptables -A INPUT -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT

7. Combine Multiple Rules Together using MultiPorts

When you are allowing incoming connections from outside world to multiple ports, instead of writing individual rules for each and every port, you can combine them together using the multiport extension as shown below.
The following example allows all incoming SSH, HTTP and HTTPS traffic.
iptables -A INPUT -i eth0 -p tcp -m multiport --dports 22,80,443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m multiport --sports 22,80,443 -m state --state ESTABLISHED -j ACCEPT

8. Allow Outgoing SSH

The following rules allow outgoing ssh connection. i.e When you ssh from inside to an outside server.
iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
Please note that this is slightly different than the incoming rule. i.e We allow both the NEW and ESTABLISHED state on the OUTPUT chain, and only ESTABLISHED state on the INPUT chain. For the incoming rule, it is vice versa.

9. Allow Outgoing SSH only to a Specific Network

The following rules allow outgoing ssh connection only to a specific network. i.e You an ssh only to 192.168.100.0/24 network from the inside.
iptables -A OUTPUT -o eth0 -p tcp -d 192.168.100.0/24 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT

10. Allow Outgoing HTTPS

The following rules allow outgoing secure web traffic. This is helpful when you want to allow internet traffic for your users. On servers, these rules are also helpful when you want to use wget to download some files from outside.
iptables -A OUTPUT -o eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
Note: For outgoing HTTP web traffic, add two additional rules like the above, and change 443 to 80.

11. Load Balance Incoming Web Traffic

You can also load balance your incoming web traffic using iptables firewall rules.
This uses the iptables nth extension. The following example load balances the HTTPS traffic to three different ip-address. For every 3th packet, it is load balanced to the appropriate server (using the counter 0).
iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 0 -j DNAT --to-destination 192.168.1.101:443
iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 1 -j DNAT --to-destination 192.168.1.102:443
iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 2 -j DNAT --to-destination 192.168.1.103:443

12. Allow Ping from Outside to Inside

The following rules allow outside users to be able to ping your servers.
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT

13. Allow Ping from Inside to Outside

The following rules allow you to ping from inside to any of the outside servers.
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT

14. Allow Loopback Access

You should allow full loopback access on your servers. i.e access using 127.0.0.1
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

15. Allow Internal Network to External network.

On the firewall server where one ethernet card is connected to the external, and another ethernet card connected to the internal servers, use the following rules to allow internal network talk to external network.
In this example, eth1 is connected to external network (internet), and eth0 is connected to internal network (For example: 192.168.1.x).
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

16. Allow outbound DNS

The following rules allow outgoing DNS connections.
iptables -A OUTPUT -p udp -o eth0 --dport 53 -j ACCEPT
iptables -A INPUT -p udp -i eth0 --sport 53 -j ACCEPT

17. Allow NIS Connections

If you are running NIS to manage your user accounts, you should allow the NIS connections. Even when the SSH connection is allowed, if you don’t allow the NIS related ypbind connections, users will not be able to login.
The NIS ports are dynamic. i.e When the ypbind starts it allocates the ports.
First do a rpcinfo -p as shown below and get the port numbers. In this example, it was using port 853 and 850.
rpcinfo -p | grep ypbind
Now allow incoming connection to the port 111, and the ports that were used by ypbind.
iptables -A INPUT -p tcp --dport 111 -j ACCEPT
iptables -A INPUT -p udp --dport 111 -j ACCEPT
iptables -A INPUT -p tcp --dport 853 -j ACCEPT
iptables -A INPUT -p udp --dport 853 -j ACCEPT
iptables -A INPUT -p tcp --dport 850 -j ACCEPT
iptables -A INPUT -p udp --dport 850 -j ACCEPT
The above will not work when you restart the ypbind, as it will have different port numbers that time.
There are two solutions to this: 1) Use static ip-address for your NIS, or 2) Use some clever shell scripting techniques to automatically grab the dynamic port number from the “rpcinfo -p” command output, and use those in the above iptables rules.

18. Allow Rsync From a Specific Network

The following rules allows rsync only from a specific network.
iptables -A INPUT -i eth0 -p tcp -s 192.168.101.0/24 --dport 873 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 873 -m state --state ESTABLISHED -j ACCEPT

19. Allow MySQL connection only from a specific network

If you are running MySQL, typically you don’t want to allow direct connection from outside. In most cases, you might have web server running on the same server where the MySQL database runs.
However DBA and developers might need to login directly to the MySQL from their laptop and desktop using MySQL client. In those case, you might want to allow your internal network to talk to the MySQL directly as shown below.
iptables -A INPUT -i eth0 -p tcp -s 192.168.100.0/24 --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT

20. Allow Sendmail or Postfix Traffic

The following rules allow mail traffic. It may be sendmail or postfix.
iptables -A INPUT -i eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT

21. Allow IMAP and IMAPS

The following rules allow IMAP/IMAP2 traffic.
iptables -A INPUT -i eth0 -p tcp --dport 143 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 143 -m state --state ESTABLISHED -j ACCEPT
The following rules allow IMAPS traffic.
iptables -A INPUT -i eth0 -p tcp --dport 993 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 993 -m state --state ESTABLISHED -j ACCEPT

22. Allow POP3 and POP3S

The following rules allow POP3 access.
iptables -A INPUT -i eth0 -p tcp --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 110 -m state --state ESTABLISHED -j ACCEPT
The following rules allow POP3S access.
iptables -A INPUT -i eth0 -p tcp --dport 995 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 995 -m state --state ESTABLISHED -j ACCEPT

23. Prevent DoS Attack

The following iptables rule will help you prevent the Denial of Service (DoS) attack on your webserver.
iptables -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
In the above example:
  • -m limit: This uses the limit iptables extension
  • –limit 25/minute: This limits only maximum of 25 connection per minute. Change this value based on your specific requirement
  • –limit-burst 100: This value indicates that the limit/minute will be enforced only after the total number of connection have reached the limit-burst level.

24. Port Forwarding

The following example routes all traffic that comes to the port 442 to 22. This means that the incoming ssh connection can come from both port 22 and 422.
iptables -t nat -A PREROUTING -p tcp -d 192.168.102.37 --dport 422 -j DNAT --to 192.168.102.37:22
If you do the above, you also need to explicitly allow incoming connection on the port 422.
iptables -A INPUT -i eth0 -p tcp --dport 422 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 422 -m state --state ESTABLISHED -j ACCEPT

25. Log Dropped Packets

You might also want to log all the dropped packets. These rules should be at the bottom.
First, create a new chain called LOGGING.
iptables -N LOGGING
Next, make sure all the remaining incoming connections jump to the LOGGING chain as shown below.
iptables -A INPUT -j LOGGING
Next, log these packets by specifying a custom “log-prefix”.
iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables Packet Dropped: " --log-level 7
Finally, drop these packets.
iptables -A LOGGING -j DROP

2/18/13

Data -> Information -> Knowledge -> Wisdom

If data is characterized as recorded facts, then information is the set of patterns, or expectations, that underlie the data. You could go on to define knowledge as the accumulation of your set of expectations and wisdom as the value attached to knowledge.

2/5/13

Building a Simple Web Service ? A Tutorial

Building a Simple Web Service ? A Tutorial

   
 By Jeevaraj Gnanaselvan Dhanaraj (jeevaraj_1970@yahoo.com)
  (Jeeva has over 7 years of experience in designing and developing enterprise class web applications using JAVA and J2EE technologies.
  He currently works for Itreya Technologies, Bangalore, leading a team of over 10 programmers and designers, developing a multi-user, distributed, web-based workflow application)
 ·  Introduction
In this tutorial we will create a simple web service and a client web application using eclipse IDE along with Lomboz plug in. We will also deploy and test the web service on Tomcat 5.5.4 web application server. This application, while simple, provides a good introduction to Web service development and some of the Web development tools available.
 ·   Environment
J2SDK 1.4.2
http://java.sun.com/
Eclipse 3.1
Tomcat 5.5.4
·   Installation
Install JDK (in D:\j2sdk1.4.2_04)
Install Tomcat (in E:\Tomcat5.5)
Install Eclipse (in E:\Eclipse3.1)
Install Lomboz (in E:\Eclipse3.1)
·   Setting up
  1. Set up the installed JRE in eclipse (Windows -> Preferences -> Java -> Installed JREs)
 
 
  1. Set up the installed runtime for server in eclipse (Windows -> Preferences -> Server -> Installed Runtimes)
 
 
  1. Set up the Server view in eclipse (Windows -> Show View -> Other)
 
  1. Set up the Tomcat Server by right clicking and selecting New -> Server option from the Server view in eclipse
 
 
 
·   Creating a Web service
  1. Create a new Dynamic Web Project in eclipse (File -> New -> Other)
 
  1. Enter name as ?WebServiceTutorial?, select project location as ?E:\Test? and select Apache Tomcat v5.5 as the Target server.
 
  1. Now create a new Java class from the Project Explorer (Dynamic Web Projects -> Java Source -> New -> Class)
 
 
  1. Enter name as ?Hello? and package as ?com.tutorial?.
 
  1. Add a simple method in the ?Hello? class as below.
  public String sayHello(String name){
  return "Hello " + name;
  }  
 
 
  1. Save and build the project.
  2. Create a new Web service in eclipse (File -> New -> Other)
 
  1. Select Generate a proxy.
  2. Select Test the Web service.
  3. Select Overwrite files without warning.
 
  1. Select or enter the Bean name as ?com.tutorial.Hello?. This is the java class that we just now created.
 
  1. Continue the wizard by clicking Next and finish.
  2. On Finish, the Tomcat server starts up and launches the Test client.
  3. Verify the generated contents. Look for Hello.class and the generated JSPs as below.
 
 
  1. Verify the Tomcat folder and ensure the newly created web applications ? WebServiceTutorial, WebServiceTutorialClient.
 
 
  1. We can also run the following url from the browser to access/test the Web service.
  1. If servlet error ?org.eclipse.jst.ws.util.JspUtils cannot be resolved or is not a type? is thrown on the browser, then copy the webserviceutils.jar file from the E:\Eclipse3.1\eclipse\plugins\org.eclipse.jst.ws.consumption_0.7.0 into the WEB-INF\lib folder of the WebServiceTutorialClient application and restart the Tomcat server.
  1. The browser displays the methods available in the web service.
 
  1. Click on the sayHello(..) method, enter your name (for e.g. ?Jeeva?) in the inputs section and click ?Invoke?.
 
 
  1. The browser greets using the web service.

 
  1. The WSDL for the Hello Web service can be found in E:\Test\WebServiceTutorial\WebContent\wsdl\Hello.wsdl. On double-click, the WSDL opens in a graphical editor.
 
 
  1. Right-click on the WSDL file and explore the options to test the web service / publish the WSDL file / generate client / etc.
 
 
·   Conclusion
In this tutorial we learned how to create a simple web service and a client web application using eclipse IDE along with Lomboz plug in. We also deployed and tested the web service on Tomcat 5.5.4 web application server. This application, while simple, provides a good introduction to Web service development and some of the Web development tools available.

1/11/13

The Phases of the KDD Process


The Phases of the KDD Process

A KDD process consists of several tasks. Indeed, the actual mining, that is to say the application of a data mining algorithm to a dataset, is only one of these steps. Following the CRISP-Data Mining model [9,31] we distinguish the following tasks:

1. Business Understanding
The very first step of a KDD project should be a close look from the business point of view. The goal of this phase is to gain a deeper understanding of the project objectives and further circumstances strictly from the business perspective. Finally the insights from this initial phase are to be turned into a data mining problem definition.

2. Data Understanding
Based on the results from the business point of view the second step is to get familiar with the available data. The goal is to understand the attributes and the corresponding attribute values and to find out hidden semantics possibly in the data. Furthermore at this stage one should figure out what exactly the available data offers. That is to say, whether it has the potential to answer our mining questions or not, and if possible to select promising subsets of the data.

3. Data Preparation
The next step is to construct the dataset where the mining algorithm is to be run on. This phase covers both syntactic aspects – format transformations for the employed mining algorithm – and semantic aspects like table, record and attribute selection. Last but not least this phase also includes deriving new attributes that contain higher information only implicitly contained in the raw data (e.g. deriving “day of the week” from “date”).

4. Modeling (or Mining)
In the modeling phase the actual data mining takes place. Based on the identified business goals and the assessment of the available data an appropriatemining algorithm is chosen and run on the prepared data.

5. Evaluation
Evaluating the results of the mining run mainly covers three aspects. First of all, it is necessary to ensure whether everything went right from the technical point of view. Was the mining algorithms finally able to read and interpret the prepared dataset correctly? Were all designated information actually given to the algorithm? Etc. Second, one needs to investigate whether the mining results are sound from the mining methods point of view. Some methods directly support this decision by computing certain significance measures whereas others leave this aspect completely to the analyst and his experience. Third, a key objective of the evaluation phase is to determine if all important business issues have been considered adequately.

6. Deployment
After mining the data and assessing the data mining results one needs to transfer the results back into the business environment. This can be rather straight forward like preparing the results in form of a report that is understandable by business people (who of course typically are non data mining experts). Or, as the other extreme, can be quite complex like implementing a repeatable data mining process across the enterprise.

1/10/13

UML Tools for Ubuntu

UML Tools for Ubuntu

Unified Modelling Language (UML) is basically a modelling languages that is typically used in the design phase of object oriented software development process, to express the thought in graphical representation, to visualize the system etc. UML, created by OMG (Object Management Group), has now become the standard approach to software modelling. In fact the UML diagrams makes coding part easier in complex systems, so the time you would spent in drawing will save you a lot of time (later, during development/implementation phase). UML diagrams represents – Static as well as Dynamic views of a system, so using UML tools you can draw – class diagrams, activity diagrams, sequence diagrams, use case diagrams etc.
There are various tools available such as IBM Rational Rose, for drawing UML diagrams but in this post you are going to know about some open source modelling tools, that you can use on your Linux based Operating systems e.g Ubuntu 11.04 (Natty Narwhal) /11.10 (Oneiric Ocelot, the code name of upcoming version)/ or older versions such as 10.10/10.04 LTS…, Linux Mint, Fedora, OpenSuse etc.

UML Modelling Tools for Ubuntu (11.04/11.10/10.04/10.10..) or other Linux OS

Here are some of the most popular free and open source UML Modelling softwares that you can use with Ubuntu or other Linux distro, some of them are cross-platform i.e also available for Windows and Mac OS. Try some of them and choose the one which suits you best.

Umbrello UML Modeller

Umbrello is a KDE based software for creating UML diagrams in standard format. It supports a lot of languages and code generation (advanced code generation is available for ruby) is also supported, it has all basic features – that you expect from a UML tool.
umbrello-uml-modelling-tool
Download Umbrello UML Tool or better install it from command line (in Ubuntu or Debian based system) -
sudo apt-get install umbrello

Gaphor

Gaphor is a cross-platform UML tool with simplicity, before installing it be sure to check for its dependencies such as Python (version 2.5 or later).
Download Gaphor
gaphor-uml-tool-for-ubuntu

ArgoUML

ArgoUML is one of the best open source – ‘software modelling tool’ with a lot of advanced features. It is a java based (and of course cross-platform) application.
argouml-snapshot
The supported diagrams are -
  • class diagrams
  • statechart diagrams
  • use case diagrams
  • activity diagrams
  • sequence diagram
  • deployment diagram
Download ArgoUML (Latest version 0.32.2 was released on April, 2011)

Dia

Dia is a GTK based drawing program that can be used for drawing UML diagrams, Flowcharts, Network diagrams etc.
Download Dia

1/8/13

How to Turn Your Ubuntu Laptop into a Wireless Access Point

How to Turn Your Ubuntu Laptop into a Wireless Access Point

image
If you have a single wired Internet connection – say, in a hotel room – you can create an ad-hoc wireless network with Ubuntu and share the Internet connection among multiple devices. Ubuntu includes an easy, graphical setup tool.
Unfortunately, there are some limitations. Some devices may not support ad-hoc wireless networks and Ubuntu can only create wireless hotspots with weak WEP encryption, not strong WPA encryption.

Setup

To get started, click the gear icon on the panel and select System Settings.

Select the Network control panel in Ubuntu’s System Settings window. You can also set up a wireless hotspot by clicking the network menu and selecting Edit Network Connections, but that setup process is more complicated.

If you want to share an Internet connection wirelessly, you’ll have to connect to it with a wired connection. You can’t share a Wi-Fi network – when you create a Wi-Fi hotspot, you’ll be disconnected from your current wireless network.

To create a hotspot, select the Wireless network option and click the Use as Hotspot button at the bottom of the window.

You’ll be disconnected from your existing network. You can disable the hotspot later by clicking the Stop Hotspot button in this window or by selecting another wireless network from the network menu on Ubuntu’s panel.

After you click Create Hotspot, you’ll see an notification pop up that indicates your laptop’s wireless radio is now being used as an ad-hoc access point. You should be able to connect from other devices using the default network name – “ubuntu” – and the security key displayed in the Network window. However, you can also click the Options button to customize your wireless hotspot.

From the wireless tab, you can set a custom name for your wireless network using the SSID field. You can also modify other wireless settings from here. The Connect Automatically check box should allow you to use the hotspot as your default wireless network – when you start your computer, Ubuntu will create the hotspot instead of connecting to an existing wireless network.

From the Wireless Security tab, you can change your security key and method. Unfortunately, WPA encryption does not appear to be an option here, so you’ll have to stick with the weaker WEP encryption.

The “Shared to other computers” option on the IPv4 Settings tab tells Ubuntu to share your Internet connection with other computers connected to the hotspot.

Even if you don’t have a wireless Internet connection available to share, you can network computers together and communicate between them – for example, to share files.

1/7/13

Install Java JDK 7 in Ubuntu 12.04

Install Java JDK 7 in Ubuntu 12.04


This package provides Oracle Java JDK 7 (which includes JRE and the Java browser plugin). However, you can’t only install Oracle JRE – the PPA only provides the full Oracle JDK7 package.
1. To add our PPA and install the latest Oracle Java (JDK) 7 in Ubuntu, use the commands below:
#sudo add-apt-repository ppa:webupd8team/java

#sudo apt-get update && sudo apt-get install oracle-jdk7-installer
2. After install you have enable the jdk:
#update-alternatives –display java

3. Check if Ubuntu uses Java JDK 7
#java -version

If all went right the answer should be:
java version “1.7.0_07″

Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) Server VM (build 23.3-b01, mixed mode)

4. Check what compiler is used:
#javac -version

The correct answer:
javac 1.7.0_07

5. Adding JAVA_HOME to environment
Edit
/etc/environment and add JAVA_HOME=/usr/lib/jvm/java-7-oracle to the end of the file.
First open a Terminal (Applications → Accessories → Terminal), then enter:
#sudo gedit /etc/environment
Append to the end of the file:
JAVA_HOME=/usr/lib/jvm/java-7-oracle
6. Removing Oracle JDK 7
If you don’t want to use Oracle Java (JDK) 7 anymore and want to go back to OpenJDK, all you have to do is remove the Oracle JDK7 Installer and the previous Java (OpenJDK, etc.) version will be used:
#sudo apt-get remove oracle-jdk7-installer