Saturday, 29 December 2012

Doomsday Special: Doomsday aftermath



For all those who waited for the doomsday to happen and are upset with the fact that it finally DID NOT actually take place. I have something really interesting to offer to bring your interest back to the world which apparently DID NOT end.

Let’s see the 3 major pluses for doomsday not actually happening:
1.       You get to use your apple gadgets…wallah! You still get to use your iPhone, IPad
2.       Surviving the post Doomsday destroyed  world is much more difficult then surviving this world…. So what if you don’t not get to rob all the Apple stores!
3.       Living on a totally destroyed planet under the pressure of building it all over again …well  trust me it would have been real pain in the a**  … so thank God that he saved you from all that pain .


So i hope finally 'to some extent' you will be able to live with the fact that yippiiiiiee ! doomsday did not happen :)


Monday, 5 November 2012

In 3 Different Integer Array Print the Combination of 3 Array Element that Sum upto Zero


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkg3arraysum;

/**
 *
 * @author Sunshine
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int a1[] = new int[]{2, -3, 7, 8};
        int a2[] = new int[]{4, -6, 2, -1};
        int a3[] = new int[]{-6, 4, 7, 0};

        sort(a1);
        sort(a2);
        sort(a3);
     
        int sum;
     
        for(int i=0;i<a1.length;i++){
            int j=0,k=a3.length-1;
            while(j<a2.length && k>0){
               sum=a1[i]+a2[j]+a3[k];
               if(sum>0)
                   --k;
               else if(sum<0)
                   ++j;
               else if(sum==0)
                  System.out.println(a1[i]+"+"+a2[j]+"+"+a3[k]+"=0");
            }
            }
     
    }

    public static void sort(int[] a) {
        int j;
        boolean flag = true;
        int temp;

        while (flag) {
            flag = false;
            for (int i = 0; i < a.length - 1; i++) {
                if(a[i]>a[i+1]){
                temp = a[i];
                a[i] = a[i + 1];
                a[i + 1] = temp;
                flag = true;
                }
            }
        }
    }
}

String Manipulation - Printing Sub Strings of a String in Incremental Order & Replacing '=' When StringIndexOutOfBoundsException Occurs


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package something;

import java.util.List;

/**
 *
 * @author Sunshine
 */
public class Something {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
           String input = "RaviKiran";  
     
        int index = 0;
        for (int i = 1;    ; i++) {                
            for (int j = 0; j < i; j++) {
                try {
                System.out.print(input.charAt(index));
                } catch (StringIndexOutOfBoundsException ex) {              
                    System.out.print("=");
                }
                index++;
            }
            System.out.println();
            if (index >= input.length()) {
                break;
            }
    }
}
}


OUTPUT


run:
R
av
iKi
ran=
BUILD SUCCESSFUL (total time: 0 seconds)


Java: In place Negative and Positive separation Of Elements in an Array


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package separateposneg;

/**
 *
 * @author Sunshine
 */
public class SeparatePosNeg {

    /**
     * @param args the command line arguments
     */
   public static void main(String[] args) {
        // TODO code application logic here
        int array[] = new int[]{2, -7, -6, -9, -5, 11, -19, 8, 14, 17};
        int neg,pos=0, temp;
        int n = array.length;
        for (int i = 0; i < n; i++)
        {
            if (array[i] > 0)
            {          
                temp=array[i];
                array[pos]=temp;            
                pos++;          
                for(int k =i ; k >pos ;k--)
                {            
                 array[k]=array[k-1];
                }          
            }
}
 for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);        }
    }
}

Tuesday, 25 September 2012

Java Beginner : Strings and Arrays - Display words that start with a vowel in an user inserted string


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication7;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Sunshine
 */
public class JavaApplication7 {

    /**

     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        System.out.println("Please enter some text");
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String names=br.readLine().toLowerCase();
        StringTokenizer stk=new StringTokenizer(names);
        String vowels="";
        while(stk.hasMoreTokens()){
            String c=stk.nextToken();
            if(c.startsWith("a")||c.startsWith("e")||c.startsWith("i")||c.startsWith("o")||c.startsWith("u"))
                vowels=vowels+" "+c;
        }
        System.out.println(vowels);
        
    }
}



Java Beginner : Strings and Arrays - Display second largest element in the array of names


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication6;

/**
 *
 * @author Sunshine
 */
public class JavaApplication6 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
         String[] names = new String[]{"ravi kiran", "aarushi madiratta", "himani jain", "nancy agarwal","manish kapoor","poonam yadav","silko malik"};
        bubblesort(names);
      
       System.out.println("The second largest element in the arraay of names is : "+names[names.length-2].toUpperCase());
      


    }

    public static void bubblesort(String[] text) {
        int j;
        boolean flag = true;
        String temp;

        while (flag) {
            flag = false;
        
        for (int i = 0; i < text.length - 1; i++) {
            if (text[i].compareToIgnoreCase(text[i + 1]) > 0) {
                temp = text[i];
                text[i] = text[i + 1];
                text[i + 1] = temp;
                flag = true;
            }
        }
    }
    }
}
    



Java Beginner : Strings and Arrays - Sort Array of names


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication5;

/**
 *
 * @author Sunshine
 */
public class JavaApplication5 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        String[] names = new String[]{"ravi kiran", "arushi madiratta", "himani jain", "nancy agarwal","manish kapoor","poonam yadav","silko malik"};
        bubblesort(names);
        for (int i = 0; i < names.length; i++) {
            System.out.println(names[i]);
        }


    }

    public static void bubblesort(String[] text) {
        int j;
        boolean flag = true;
        String temp;

        while (flag) {
            flag = false;
        }
        for (int i = 0; i < text.length - 1; i++) {
            if (text[i].compareToIgnoreCase(text[i + 1]) > 0) {
                temp = text[i];
                text[i] = text[i + 1];
                text[i + 1] = temp;
                flag = true;
            }
        }
    }
}






Java Beginner : Strings and Arrays - Sort a user inserted string


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication4;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author Sunshine
 */
public class JavaApplication4 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        
        System.out.println("Please enter the text");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String inp = br.readLine().toLowerCase();
        char[] input=inp.toCharArray();
        Arrays.sort(input);
        
            System.out.println(input);
       
        
    }
}



Java Beginner : Strings and Arrays - Count the number of occurrences of each vowel in a string


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author Sunshine
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        System.out.println("Enter some text");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine().toLowerCase();
        
        char[] vowel = new char[]{'a', 'e', 'i', 'o', 'u'};
        int[] countVowel = new int[5];
        for (int j = 0; j < input.length(); j++) {
            char c =input.charAt(j);
            if(c=='a')
                countVowel[0]++;
            else if(c=='e')
                countVowel[1]++;
            else if(c=='i')
                countVowel[2]++;
            else if(c=='o')
                countVowel[3]++;
            else if(c=='u')
                countVowel[4]++;
           

        }
         for (int i = 0; i <countVowel.length; i++) {
                System.out.println("Count of vowel " + vowel[i] + "=" + countVowel[i]);
            }
            
        }
    }



Tuesday, 11 September 2012

Session tracking: URL Encoding Technique in Java Servlets


The structure of the application is like this:



Encode.jsp


<%-- 
    Document   : encode
    Created on : Sep 11, 2012, 12:12:41 PM
    Author     : Sunshine
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>lets do URL encoding!</h1>
        <c:url value="http://localhost:8080/SimpleCookies/decode.jsp" var="decoderpage"/>
        <a href="<c:out value="${decoderpage}"/>">click here</a>
            
    </body>
</html>


decode.jsp
<%-- 
    Document   : decode
    Created on : Sep 11, 2012, 12:12:53 PM
    Author     : Sunshine
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        String descriptor;
        if(session.isNew())
            descriptor="This is a new session";
        else
            descriptor="This is not a new session";
        %>
        <br>
        <h1>Session description:</h1>
        <%=descriptor%>
        <br>
        <hr>
        <%
        String id=session.getId();
        %>
        <br>
        <h2>The session Id is:</h2>
        <%=id%>
        <br>
       
    </body>
</html>




Monday, 10 September 2012

Simple Registration Page with Database Connectivity in HTML and PHP: Part 2


<?php

$getuser=$_POST['username'];
$getemail=$_POST['email'];
$getpwd=$_POST['password'];
$getpassword=$_POST['cnfpwd'];
$getname=$_POST['fullName'];


if(strlen($getemail>=7)&&(strstr($getemail,"@")&&(strstr($getemail,"."))))
{
require("connection.php");
$query=mysql_query("SELECT * FROM registeration WHERE username='$getuser'");
$numrows=mysql_num_rows($query);
if($numrows==0)
{
$query=mysql_query("SELECT * FROM registeration WHERE email='$getemail'");
$numrows=mysql_num_rows($query);
if($numrows==0)
{
$code=rand(11111111,99999999);
mysql_query("INSERT INTO registeration(fullName,age,gender,DOB,address,phone,qualification,workExperience,Institute,email,username,maritalStatus,expertise,password,active,code,date) VALUES ('$_POST[fullName]','$_POST[age]','$_POST[gender]','$_POST[DOB]','$_POST[address]','$_POST[phone]','$_POST[qualification]','$_POST[workExperience]','$_POST[Institute]','$_POST[email]','$_POST[username]','$_POST[maritalStatus]','$_POST[expertise]','$_POST[password]','0','$code',SYSDATE())");
$query=mysql_query("SELECT * FROM registeration WHERE username='$getuser'");
$numrows=mysql_num_rows($query);
if($numrows==1)
{
$site="http://localhost/projectname";
$webmaster="abc@xyz.com";
$headers="From: $webmaster";
$subject="Activate Your Account";
$message="Hello $getuser \n\nThank you for registring with us .click the link to activate your account";
$message.="$site/activate.php?code=$code\n";
$message.="You must activate your account to login";
if(mail($getemail,$subject,$message,$hearders))
{
echo"you have been registered";
$getuser="";
$getemail="";
$getpwd="";
$getpassword="";
}
else
echo"An error occoured .your activation email was not sent";
}
else
echo"an error occured";
}
else
echo"There is already an user with that email";
}
}
else
echo"you must enter a valid email address";


?>

connection.php



<?php
mysql_connect("localhost","username","password");
mysql_select_db("databasename");
?>

Simple Registration Page with Database Connectivity in HTML and PHP: Part 1


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LBSIM-Conference Management System</title>

<link href="css/Navbar.css" rel="stylesheet" type="text/css" />
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="Image/Background.jpg">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<script>
function validate(){
    if(document.form.fullName.value == ""){
        alert( "Name cannot be empty" );
        document.form.fullName.focus();
        return false;
    }
    if(document.form.age.value == ""){
        alert( "Age cannot be empty" );
        document.form.age.focus();
        return false;
    }
    if(document.form.email.value == ""){
        alert( "Email cannot be empty" );
        document.form.email.focus();
        return false;
    }
 if(document.form.password.value == ""){
        alert( "Password cannot be empty" );
        document.form.password.focus();
        return false;
    }
    if(document.form.username.value == ""){
        alert( "username cannot be empty" );
        document.form.username.focus();
        return false;
    }
    if(document.form.cnfpwd.value == ""){
        alert( "Confirm Password cannot be empty" );
        document.form.cnfpwd.focus();
        return false;
    }
 if(document.form.cnfpwd.value ==document.form.password.value ){
        alert( "Passwords match" );
        document.form.cnfpwd.focus();
        return true;
    }
 if(document.form.password.value.length<8 ){
        alert( "Password should be have atleast 8 character" );
        document.form.password.focus();
        return false;
    }
 if(document.form.cnfpwd.value !==document.form.pwd.value ){
        alert( "Passwords match" );
        document.form.cnfpwd.focus();
        return false;
    }
    if(document.form.phone.value == ""){
        alert( "Phone Number cannot be empty" );
        document.form.phone.focus();
        return false;
    }
 if(document.form.qualification.value == ""){
        alert( "Qualification cannot be empty" );
        document.form.qualification.focus();
        return false;
    }
 if(document.form.gender.value == 0){
        alert( "Please select a gender" );
        document.form.gender.focus();
        return false;
    }
 if(document.form.address.value == 0){
        alert( "Address field can not be left empty" );
        document.form.address.focus();
        return false;
    }
 if(document.form.Institute.value == 0){
        alert( "Institute field can not be left empty" );
        document.form.Institute.focus();
        return false;
    }
 if(document.form.expertise.value == 0){
        alert( "Area of Expertise field can not be left empty" );
        document.form.expertise.focus();
        return false;
    }
 if(document.form.workExperience.value == 0){
        alert( "Please enter your work experience" );
        document.form.workExperience.focus();
        return false;
    }
 
 alert("Registration Successfull !");
 window.open("Login.html");
    return true;   
    }  
</script>
<tr>
<td>
<img src="Image/bannersketch.png" width="90%" height="90" />
</td>
</tr>
<tr>
<td>
<div id="navbar" style="margin-top:10px;margin-bottom:20px">
<ul>
<li><a href ="CMS.html" title="View home Page">Home</a></li>
<li><a href ="Login.html" title="Go to Login page">Login</a></li>

<li><a href="PDF/Document1.pdf" title="Reseach Paper Submission Guidelines to Authors">Guidelines</a></li>
<li><a href ="Help.html" onmouseover="Show()" onmouseout="Hide()">Help</a></li>
<li><a href ="Contact.html" title="Contact technical support">Contact</a></li>
<li><a href ="FAQ.html" title="View Frequently asked questions">FAQ</a></li>
</ul>
</div>
</td>
</tr>
<div>
<tr>
<td>
<form name="form" method="post" align = "center" onsubmit="return validate();" action="reg.php">

<font color="blue"><b>
Name:<input type="text" name="fullName" maxlength="16"></br>
Age:<input type="text" name="age" maxlength="2"></br>
Date Of Birth:<input type="text" name="DOB" maxlenght="10"></br>
<label>Gender:</label>
<input type="radio" name="gender" value="male" /> Male
<input type="radio" name="gender" value="female" /> Female</br>
<label>Marital Status:</label><input type="radio" name="maritalStatus" value="single" />Single
<input type="radio" name="maritalStatus" value="married" /> Married</br>
<label>Qualification:</label></br>
<textarea name="qualification" rows="5" cols="20" maxlength="50"></textarea> </br>
Address:<input type="textarea" name="address" maxlength="50"></br>
Email:<input type="text" name="email" maxlength="30"></br>
Phone Number:<input type="text" name="phone" maxlength="10"></br>
Institute:<input type="text" name="Institute" maxlength="50"></br>
Area of Expertise:<input type="text" name="expertise" maxlength="30"></br>
Work Experience:<input type ="text" name="workExperience" maxlength="2"></br>
<hr/></font>
<font color="red"><i>
<p> Please Create a user account with us that would be used for next time Login</p>
Username:<input type="text" id="username" name="username" maxlength="20" minlength="10">
<br/>
Password:<input type="password" id="pwd" name="password" maxlength="20" minlength="8"></br>
Confirm Password:<input type="password" name="cnfpwd" id="cnfpwd" maxlength="20" minlength="8">
</b></i></font></br>
<input type="submit" value="register" name="register" align="middle">
</table>
</form>
</td>
</tr>
</div>
<tr>
<td>

</div>
</div>
</td>
</tr>
<tr align="center" height="100">
<td>
<div id="copyright" style="background-color:#999999;width:100%">
<div style="border=1px solid gray; margin-top:10px">
<ul>
<b>Copyright </b>
</ul>
</div>
</div>
</td>
</tr>
</body>
</html>

Few Basic linux Commands




1.                   cat -concatenate files and print on the standard Output

Syntax:

cat [OPTION] [FILE]...

Description

Concatenate FILE(s), or standard input, to standard Output.
-A, --show-all
equivalent to -vET
-b,--number-nonblank
number nonempty Output lines
-e
equivalent to -vE
-E, --show-ends
display $ at end of each line
-n, --number
number all Output lines
-s, --squeeze-blank
suppress repeated empty Output lines
-t
equivalent to -vT
-T, --show-tabs
display TAB characters as ^I
-u
(ignored)
-v, --show-nonprinting
use ^ and M- notation, except for LFD and TAB
--help
display this help and exit
--version
Output version information and exit
With no FILE, or when FILE is -, read standard input.



Output:
sunshine@ubuntu:/home$ cat /home/sunshine/Desktop/hello1 /home/sunshine/Desktop/hello2
hi 
kiran
how are you?
hi 
kiran
how are you?

 





2.                   man- Display information from the online reference manuals. man locates and prints the named title from the
Syantax:
man [options] [section] [title]
sunshine@ubuntu:/$ man
What manual page do you want?

.Output:



2.cal-  Print a 12-month calendar (beginning with January) for the given year, or a one-month calendar of the given month and year. month ranges from 1 to 12. year ranges from 1 to 9999. With no arguments, print a calendar for the current month.
Syantax:
cal [options] [[month] year]

Options

-j
Display Julian dates (days numbered 1 to 365, starting from January 1).
-m
Display Monday as the first day of the week.
-y
Display entire year.


Output:
sunshine@ubuntu:~$ cal
    August 2012      
Su Mo Tu We Th Fr Sa 
          1  2  3  4 
 5  6  7  8  9 10 11 
12 13 14 15 16 17 18 
19 20 21 22 23 24 25 
26 27 28 29 30 31    

 










3.            date -print or set the system date and time
Syantax:
date [options] [+format] [date]

Output:
sunshine@ubuntu:~$ date
Sun Aug 19 08:11:01 PDT 2012

 





4.            ls - List contents of directories. If no names are given, list the files in the current directory. With one or more names, list files contained in a directory name or that match a file name.names can include filename metacharacters. The options let you display a variety of information in different formats. The most useful options include -F, -R, -l, and -s. Some options don't make sense together (e.g., -u and -c).
Syantax:
ls [options] [names]
Options:
-1, --format=single-column
Print one entry per line of Output.
-a, --all
List all files, including the normally hidden files whose names begin with a period.
-b, --escape
Display nonprinting characters in octal and alphabetic format.
-c, --time-ctime, --time=status
List files by status change time (not creation/modification time).
--color =when
Colorize the names of files depending on the type of file. Accepted values forwhen are never, always, or auto.
-d, --directory
Report only on the directory, not its contents.
-f
Print directory contents in exactly the order in which they are stored, without attempting to sort them.
--full-time
List times in full, rather than using the standard abbreviations.
-g
Long listing like -l, but don't show file owners.
-h
Print sizes in kilobytes and megabytes.
--help
Print a help message and then exit.
-i, --inode
List the inode for each file.
--indicator-style=none
Display filenames without the flags assigned by -p or -f (default).
-k, --kilobytes
If file sizes are being listed, print them in kilobytes. This option overrides the environment variable POSIXLY_CORRECT.
-l, --format=long, --format=verbose
Long format listing (includes permissions, owner, size, modification time, etc.).
-m, --format=commas
Merge the list into a comma-separated series of names.
-n, --numeric-uid-gid
Like -l, but use group ID and user ID numbers instead of owner and group names.
-o
Long listing like -l, but don't show group information.
-p, --filetype, --indicator-style=file-type
Mark directories by appending / to them.
-q, --hide-control-chars
Show nonprinting characters as ? (default for display to a terminal).
-r, --reverse
List files in reverse order (by name or by time).
-s, --size
Print file size in blocks.
--show-control-chars
Show nonprinting characters verbatim (default for printing to a file).
--si
Similar to -h, but uses powers of 1,000 instead of 1,024.
-t, --sort=time
Sort files according to modification time (newest first).
-u, --time=atime, --time=access, --time=use
Sort files according to file-access time.
--version
Print version information on standard Output, then exit.
-x, --format=across, --format=horizontal
List files in rows going across the screen.
-v, --sort=version
Interpret the digits in names such as file.6 and file.6.1 as versions, and order filenames by version.
-w, --width=n
Format Output to fit n columns.
-A, --almost-all
List all files, including the normally hidden files whose names begin with a period. Does not include the . and .. directories.
-B, --ignore-backups
Do not list files ending in ~ unless given as arguments.
-C, --format=vertical
List files in columns (the default format).
-D, --dired
List in a format suitable for Emacs dired mode.
-F, --classify, --indicator-style=classify
Flag filenames by appending / to directories, * to executable files, @ to symbolic links, | to FIFOs, and = to sockets.
-G, --no-group
In long format, do not display group name.
-H, --dereference-command-line
When symbolic links are given on the command line, follow the link and list information from the actual file.
-I, --ignore pattern
Do not list files whose names match the shell pattern pattern, unless they are given on the command line.
-L, --dereference
List the file or directory referenced by a symbolic link rather than the link itself.
-N, --literal
Display special graphic characters that appear in filenames.
-Q, --quote-name
Quote filenames with "; quote nongraphic characters.
-R, --recursive
List directories and their contents recursively.
-Rfile, --reload-state file
Load state from file before starting execution.
-S, --sort=size
Sort by file size, largest to smallest.
-U, sort=none
Do not sort files.
-X, sort=extension
Sort by file extension, then by filename.
Output:
sunshine@ubuntu:/$ ls
bin    dev   initrd.img  media  proc  sbin     sys  var
boot   etc   lib         mnt    root  selinux  tmp  vmlinuz
cdrom  home  lost+found  opt    run   srv      usr

 







5.                   write - write user [tty] message
Initiate or respond to an interactive conversation with user. A write session is terminated with EOF. If the user is logged into more than one terminal, specify a tty number. See also talk; use mesg to keep other users from writing to your terminal.
6.           Echo –
echo [options] [string]
Send (echo) the input string to standard Output. This is the /bin/echo command. echoalso exists as a command built into bash.

Options

-eEnable character sequences with special meaning. (In some versions, this option is not required in order to make the sequences work.)
-E Disable character sequences with special meaning.
-nSuppress printing of newline after text.
--helpPrint help message and then exit.
--versionPrint version information and then exit.

Output:
sunshine@ubuntu:~$ echo hello
hello


 



7.           df
Output:
sunshine@ubuntu:~$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1       30858908 3180476  26131784  11% /
udev              246496       4    246492   1% /dev
tmpfs             101508     756    100752   1% /run
none                5120       0      5120   0% /run/lock
none              253768     272    253496   1% /run/shm
/dev/sr0           21066   21066         0 100% /media/CDROM
/dev/sr1          718124  718124         0 100% /media/Ubuntu 12.04 LTS i386

 









8.            pwd-  print name of current/working directory
Output:
sunshine@ubuntu:~$ pwd
/home/sunshine

 




9.            free - Display statistics about memory usage: total free, used, physical, swap, shared, and buffers used by the kernel.
Syantax: free [options]
Options:
-b Calculate memory in bytes.
-k Default. Calculate memory in kilobytes.
-m Calculate memory in megabytes.
-o Do not display "buffer adjusted" line. The -o switch disables the display "-/+ buffers" line that shows buffer memory subtracted from the amount of memory used and added to the amount of free memory.
-s time Check memory usage every time seconds.
-t Display all totals on one line at the bottom of Output.
-VDisplay version information.

Output:
sunshine@ubuntu:~$ free
             total       used       free     shared    buffers     cached
Mem:        507536     501372       6164          0       5692      86872
-/+ buffers/cache:     408808      98728
Swap:       521212     226836     294376

 





10.         gzip - Compress specified files (or data read from standard input) with Lempel-Ziv coding (LZ77). Rename compressed file to filename.gz; keep ownership modes and access/modification times. Ignore symbolic links
Syantax:
gzip [options] [files] gunzip [options] [files] zcat[options] [files]
Options:
 -r, --recursive
When given a directory as an argument, recursively compress or decompress files within it.
-S suffix, --suffix suffix
Append .suffix. Default is gz. A null suffix while decompressing causesgunzip to attempt to decompress all specified files, regardless of suffix.
-t, --test
Test compressed file integrity.
-v, --verbose
Print name and percent size reduction for each file.
-V, --version
Display the version number and compilation options.
Output:
sunshine@ubuntu:/$ gzip /home/sunshine/sample1.odt

 





11.         clear - Clear the terminal display. Equivalent to pressing Ctrl-L.
12.         more - Display the named files on a terminal, one screenful at a time. See less for an alternative to more
Syantax:
more [options] [files]
Options:
+num
Begin displaying at line number num.
-num number
Set screen size to number lines.
+/pattern
Begin displaying two lines before pattern.
-c
Repaint screen from top instead of scrolling.
-d
Display the prompt "[Press space to continue, `q' to quit] " instead of ringing the bell. Also display "[Press `h' for instructions] " in response to illegal commands.
-f
Count logical rather than screen lines. Useful when long lines wrap past the width of the screen.
-l
Ignore form-feed (Ctrl-L) characters.
-p
Page through the file by clearing each window instead of scrolling. This is sometimes faster.
-s
Squeeze; display multiple blank lines as one.
-u
Suppress underline characters.

Output:
sunshine@ubuntu:~$ more
Usage: more [options] file...

 


Options:
  -d        display help instead of ring bell
  -f        count logical, rather than screen lines
  -l        suppress pause after form feed
  -p        suppress scroll, clean screen and disblay text
  -c        suppress scroll, display text and clean line ends
  -u        suppress underlining
  -s        squeeze multiple blank lines into one
  -NUM      specify the number of lines per screenful
  +NUM      display file beginning from line number NUM
  +/STRING  display file beginning from search string match
  -V        Output version information and exit

13.         who - Show who is logged into the system. With no options, list the names of users currently logged in, their terminal, the time they have been logged in, and the name of the host from which they have logged in. An optional system file (default is /etc/utmp) can be supplied to give additional information.
Syantax:
who [options] [file] who

Options:
-p, --process
Print active processes spawned by init.
-q, --count
"Quick." Display only the usernames and total number of users.
-r, --runlevel
Print the current runlevel.
-s, --short
Print only name, line, and time. This is the default behaviour.
-t, --time
Print the last system clock change.
-u, --users
Print a list of the users who are logged in.
--version
Print version information and then exit.

Output:
sunshine@ubuntu:~$ who
sunshine pts/0        2012-08-19 08:10 (:0)

 




14.         whatis who-Search the short manual page descriptions in the whatis database for each keyword and print a one-line description to standard Output for each match. Like apropos, except that it searches only for complete words. Equivalent to man -f.

Syantax:
whatis keywords
Output:
sunshine@ubuntu:~$ whatis who
who (1)              - show who is logged on

 

                                                                                         


15.               cd ..Takes you to the root directory
Output:
sunshine@ubuntu:~$ cd ..
sunshine@ubuntu:/home$ 
 






16.         sleep - Wait a specified amount of time before executing another command. units may be s(seconds), m (minutes), h (hours), or d (days). The default for units is seconds.

Syantax:
sleep amount[units] sleep option
Options:
--help
Print usage information and exit.
--version
Print version information and exit.
17.         whoami- Print current user ID. Equivalent to id -un.
Output:
sunshine@ubuntu:~$ whoami
sunshine
 





18.         bc -is a language (and compiler) whose syntax  resembles that of C, but with unlimited-precision arithmetic. bc consists of identifiers, keywords, and symbols, which are briefly described in the following entries. Examples are given at the end.
19.               Interactively perform arbitrary-precision arithmetic or convert numbers from one base to another. Input can be taken from files or read from the standard input. To exit, type quit or EOF.
Syantax:
bc [options] [files]
Options:
-h, --help
Print help message and exit.
-i, --interactive
Interactive mode.
-l, --mathlib
Make functions from the math library available.
-s, --standard
Ignore all extensions, and process exactly as in POSIX.
-w, --warn
When extensions to POSIX bc are used, print a warning.
-q, --quiet
Do not display welcome message.
-v, --version
Print version number.
Output:
sunshine@ubuntu:~$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 

 












20.         ls *odt - Lists all the odt  files in the current directory.

Output:
sunshine@ubuntu:/home$ ls *
command.odt.gz 

 






21.         uname - Print information about the machine and operating system. Without options, print the name of the kernel (Linux).
Syantax:
uname [options]
Options:
-a, --all
Combine all the system information from the other options.
-i, --hardware-platform
Print the system's hardware platform.
-m, --machine
Print the name of the hardware that the system is running on.
-n, --nodename
Print the machine's hostname.
-o, --operating-system
Print the operating system name.
-p, --processor
Print the type of processor.
-r, --kernel-release
Print the release number of the kernel.
-s, --kernel-name
Print the name of the kernel (Linux). This is the default action.
-v, --kernel-version
Print build information about the kernel.
--help
Display a help message and then exit.
--version
Print version information and then exit.
Output:
sunshine@ubuntu:~$ uname -m
i686
sunshine@ubuntu:~$ uname -i
i386

 






22.         comm -1 file1 file2-Compare lines common to the sorted files file1 and file2. Output is in three columns, from left to right: lines unique to file1, lines unique to file2, and lines common to both files.comm is similar to diff in that both commands compare two files. But comm can also be used like uniq; comm selects duplicate or unique lines between two sorted files, whereasuniq selects duplicate or unique lines within the same sorted file.
Syantax:
comm [options] file1 file2
Options:
-
Read the standard input.
-num
Suppress printing of column num. Multiple columns may be specified and should not be space-separated.
--help
Print help message and exit.
--version
Print version information and exit.
sunshine@ubuntu:~$ comm /home/sunshine/Desktop/hello1 /home/sunshine/Desktop/hello2
hi 
    Hi 
kiran
comm: file 1 is not in sorted order
how are you?
    ravi 
comm: file 2 is not in sorted order
    I am fine

Output:










23.         ps -Report on active processes. ps has three types of options. GNU long options start with two hyphens, which are required. BSD options may be grouped and do not start with a hyphen, while Unix98 options may be grouped and require an initial hyphen. The meaning of the short options can vary depending on whether or not there is a hyphen. In options, list arguments should either be comma-separated or space-separated and placed inside double quotes. In comparing the amount of Output produced, note that e prints more than a and lprints more than f for each entry.
Syantax:
ps [options]
Output:
sunshine@ubuntu:~$ ps
  PID TTY          TIME CMD
 1927 pts/0    00:00:00 bash
 2266 pts/0    00:00:00 ps

 









24.         diff-Compare two text files. diff reports lines that differ between file1 and file2. Output consists of lines of context from each file, with file1 text flagged by a < symbol and file2 text by a >symbol. Context lines are preceded by the ed command (a, c, or d) that would be used to convert file1 to file2. If one of the files is -, standard input is read. If one of the files is a directory, diff locates the filename in that directory corresponding to the other argument (e.g., diff my_dir junk is the same as diff my_dir/junk junk). If both arguments are directories, diff reports lines that differ between all pairs of files having equivalent names (e.g., olddir/program and newdir/program); in addition, diff lists filenames unique to one directory, as well as subdirectories common to both
Syantax:
diff [options] [diroptions] file1 file2
Output:
sunshine@ubuntu:~$ diff /home/sunshine/Desktop/hello1 /home/sunshine/Desktop/hello2
1,3c1,3
< hi 
< kiran
< how are you?
---
> Hi 
> ravi 
> I am fine

 





                                                                                    







25.         topProvide information (frequently refreshed) about the most CPU-intensive processes currently running. You do not need to include a - before options.
Syantax:
top [options]
Options:
-b
Run in batch mode; don't accept command-line input. Useful for sending Output to another command or to a file.
-c
Show command line in display instead of just command name.
-d delay
Specify delay between refreshes.
-f
Add or remove fields or columns.
-h
Print a help message and exit.



Output:

Swap:   521212k total,   188748k used,   332464k free,    83616k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
  886 root      20   0  244m 105m 3304 S  5.8 21.3   2:37.32 Xorg               
 2469 sunshine  20   0 54724  17m 8896 S  2.9  3.6   0:01.04 python             
 1920 sunshine  20   0 89612 7632 4460 S  1.6  1.5   0:05.18 gnome-terminal     
 2043 sunshine  20   0  424m 108m  14m S  1.6 21.8   1:18.76 firefox            
 1575 sunshine  20   0  6756 2184  564 S  1.3  0.4   0:06.38 dbus-daemon        
 1525 sunshine  20   0 54904 1188  944 S  1.0  0.2   0:00.16 gnome-keyring-d    
 1624 sunshine  20   0  273m  24m 6052 S  1.0  4.9   0:27.95 unity-2d-shell     
 1647 sunshine  20   0 49824 2288 1088 S  1.0  0.5   0:14.47 bamfdaemon  
 










26.               init - System administration command. Initialize system. Usually run from the boot loader—e.g.,lilo or grub.
Boot flags
-a,auto
Set the AUTOBOOT environment variable to yes. The boot loader will do this automatically when booting with the default command line.
-b
Boot directly into a single-user shell for emergency recovery.
-s,S,single
Single-user mode.
-b,emergency
Boot into single-user mode but do not run any other startup scripts.
-z characters
The specified characters are ignored, but will make the command line take up a bit more room on the stack. init uses the extra space to show the current runlevel when running the ps command.
Files
init is the first process run by any Unix machine at boot time. It verifies the integrity of all filesystems and then creates other processes, using fork and exec, as specified by/etc/inittab. Which processes may be run is controlled by runlevel. All process terminations are recorded in /var/run/utmp and /var/log/wtmp. When the runlevel changes, init sends SIGTERM and then, after 20 seconds, SIGKILL to all processes that cannot be run in the new runlevel.
Runlevels
The current runlevel may be changed by telinit, which is often just a link to init. The default runlevels vary from distribution to distribution, but these are standard:
0
Halt the system.
1, s, S
Single-user mode.
3
Multiuser mode, console login. This is commonly used in server configurations.
5
Full graphical mode. This is a common default for desktop configurations.
6
Reboot the system. Never set the default runlevel to 6.
q, Q
Reread /etc/inittab.
Check the /etc/inittab file for runlevels on your system.

Output:
sunshine@ubuntu:~$ init
init: Need to be root
 

                                                              




27.         su-Create a shell with the effective user ID user. If no user is specified, create a shell for a privileged user (i.e., become a superuser). Enter EOF to terminate. You can run the shell with particular options by passing them as shell_args (e.g., if the shell runs bash, you can specify -c command to execute command via bash, or -r to create a restricted shell).
Options:
-, -l, --login
Go through the entire login sequence (i.e., change to user's environment).
-c command, --command=command
Execute command in the new shell and then exit immediately. If command is more than one word, it should be enclosed in quotes. For example:
su -c 'find / -name \*.c -print' nobody
-f, --fast
Start the shell with the -f option, which suppresses the reading of the .cshrcor .tcshrc file. Applies to csh and tcsh.
-m, -p, --preserve-environment
Do not reset environment variables.
-s shell, --shell=shell
Execute shell, not the shell specified in /etc/passwd, unless shell is restricted.
--help
Print a help message and then exit.
--version
Print version information and then exit.

Syantax:
su [option] [user] [shell_args]

28.         runlevel-System administration command. Display the previous and current system runlevels as reported in the utmp file. The default utmp file is /var/run/utmp. See init for a summary of runlevels.

Syantax:
runlevel [utmp]
Output:
sunshine@ubuntu:/$ runlevel
N 2

 





29.         history – Displays the history of the commands executed on the shell.
Output:
sunshine@ubuntu:~$ history 5

   42  time
   43  bc
   44  history
   45  $PATH
   46  history 5

 







30.         $PATH
Output:
sunshine@ubuntu:~$ $PATH
bash: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: No such file or directory

 






31.         Touch-change file timestamps
For one or more files, update the access time and modification time (and dates) to the current time and date. touch is useful in forcing other commands to handle files a certain way; for example, the operation of make, and sometimes find, relies on a file's access and modification time. If a file doesn't exist, touch creates it with a file size of 0.
Syantax:
touch [options] files
Options:
-a, --time=atime, --time=access, --time=use
Update only the access time.
-c, --no-create
Do not create any file that doesn't already exist.
-d time, --date time
Change the time value to the specified time instead of the current time. timecan use several formats and may contain month names, time zones, a.m. and p.m. strings, etc.
-m, --time=mtime, --time=modify
Update only the modification time.
-r file, --reference file
Change times to be the same as those of the specified file, instead of the current time.
-t time
Use the time specified in time instead of the current time. This argument must be of the format [[ccyymmddhhmm[.ss] , indicating optional century and year, month, date, hours, minutes, and optional seconds.
--help
Print help message and then exit.
--version
Print the version number and then exit.

Output:
sunshine@ubuntu:~$ touch /home/Desktop/sunshine/hello1

 


32.         tail-Output the last part of files
Syantax:
tail [options] [files]
Output:
sunshine@ubuntu:~$ tail /home/sunshine/Desktop/hello1
to
you
since 
it
has
been long 
we have 
not spoken
to each
other
 











                                                                   
33.         head- Output the first few lines of files

Syantax:
head [options] [files]
Output:
sunshine@ubuntu:~$ head /home/sunshine/Desktop/hello1
hi 
kiran
how are you?
I 
wanted 
to talk
to
you
since 
it
 













34.         sort -Sort the lines of the named files. Compare specified fields for each pair of lines; if no fields are specified, compare them by byte, in machine-collating sequence. If no files are specified or if the file is -, the input is taken from standard input. See also uniq, comm, and join.
Syntax:
sort [options] [files]
Options:
-b, --ignore-leading-blanks
Ignore leading spaces and tabs.
-c, --check
Check whether files are already sorted and, if so, produce no output.
-d, --dictionary-order
Sort in dictionary order.
-f, --ignore-case
Fold; ignore uppercase/lowercase differences.
-g, --general-numeric-sort
Sort in general numeric order.
--help
Print a help message and then exit.

Output:
sunshine@ubuntu:~$ sort -c /home/sunshine/Desktop/hello1
sort: /home/sunshine/Desktop/hello1:3: disorder: how are you?
 



35.         yes- Output a string repeatedly until killed

36.         Cp- copy files and directories
Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten).
Syantax:
cp [options] file1 file2 cp [options] files directory
Options:
-a, --archive
Preserve attributes of original files where possible. The same as -dpr.
-b, --backup
Back up files that would otherwise be overwritten.
-d, --no-dereference
Do not dereference symbolic links; preserve hard-link relationships between source and copy.
-f, --force
Remove existing files in the destination.
-i, --interactive
Prompt before overwriting destination files. On most systems, this flag is turned off by default except for the root user, who is normally prompted before overwriting files.
-l, --link
Make hard links, not copies, of nondirectories.
-p, --preserve
Preserve all information, including owner, group, permissions, and timestamps.

Ouput:
sunshine@ubuntu:~$ cp /home/sunshine/Desktop/hello1 /home/sunshine/Desktop/hello2
 





37.         whoami -print effective userid

Output:
sunshine@ubuntu:~$ whoami
sunshine
 





38.         tar- Copy files to or restore files from an archive medium. If any files are directories, tar acts on the entire subtree. Options need not be preceded by - (though they may be). The exception to this rule is when you are using a long-style option (such as --modification-time).
Syantax:
tar [options] [tarfile] [other-files]
39.         time-run programs and summarize system resource usage
Syantax:
time [options] command [arguments]
Output:
sunshine@ubuntu:~$ time

real    0m0.001s
user    0m0.000s
sys    0m0.000s


 





40.         ping - System administration command. Confirm that a remote host is online and responding.ping is intended for use in network testing, measurement, and management. Because of the load it can impose on the network, it is unwise to use ping during normal operations or from automated scripts.
Syantax:
ping [options] host
Options:
-a
Make ping audible. Beep each time response is received.
-A
Adapt to return interval of packets. Like -f ping, sends packets at approximately the rate at which they are received. This option may be used by an unprivileged user.
-b
Ping a broadcast address.
-B
Bind to original source address and do not change.
-c count
Stop after sending (and receiving) count ECHO_RESPONSE packets.

Output:
sunshine@ubuntu:/home$ ping -B
Usage: ping [-LRUbdfnqrvVaAD] [-c count] [-i interval] [-w deadline]
            [-p pattern] [-s packetsize] [-t ttl] [-I interface]
            [-M pmtudisc-hint] [-m mark] [-S sndbuf]
            [-T tstamp-options] [-Q tos] [hop1 ...] destination