Monday, September 10, 2012

Fourth session of Some of basic UNIX commands that are useful very frequently


Today we are going to have some useful information on very useful command 'find' in UNIX systems. find is a command used to search any set of directories that you specified for searching files that matched your search criteria. It is useful to locate the path of files on a UNIX/LINUX system. Below is sample syntax:

 find where-to-look criteria  

  find . -name "*.java" 

Above command will display all the files that have file name extension as '.java'in the current directory.  

find . -mtime 1 

Above command will display all the files that are modified exactly one day in the current directory.  

find .. -mtime -1 

Above command will display all the files that are modified less than one day in the parent directory i.e. suppose if you are in directory '/x/y' then above command will display all files that are modified less than one day in 'x' directory. It will also include 'y' directory in searching.

 find . -perm 444 'perm' 

sub-option is used to search files based up on permissions. I.e. Above command will display all the files that have permission to read for owner,group and others in the current directory. Here in '444', first '4'indicates read permission to current user. Second '4'indicates read permission to current group that current user belongs to. Third '4'indicates read permission to other users that are in current system.

 find . -iname "string" 

If you want to search with case insensitive then you can use option '-i' preceding 'name'. I.e. Above command will display all files that have word 'string' irrespective of case. 

As specified in my previous post, you can also get more information about this command by hitting 'man find' in your terminal.

Sunday, September 9, 2012

Third session of Some of basic UNIX commands that are useful very frequently

Hey Folks,

Am back for continuing on posting some more of UNIX commands that are useful whenever you are using any UNIX based operating System.

Grep is a command which is useful for searching any word/name of file/partial name of file in a working directory or any path mentioned. This will display with both case sensitive and case-insensitive results based on the command specified..

grep -i "searchword" FILE

Above command will search for 'searchword' in file named 'FILE' and display matching lines in that file as a result.

We can also use regular expressions to search as per our requirements.

grep "string.*string1" file

Above command will display any line that has 'string' starting with and 'string1'ending with and anything in between... in the file named 'file'.

A regular expression may be followed with one of the following operators.

? The preceding item is matched with at most one time.
* The preceding item is matched with zero or more times.
+ The preceding item is matched with one or more times.
{n,m} The preceding item is matched with minimum 'n' times and maximum 'm' times.

Like this you can use of regular expression for searching your patterns.

In this way 'grep' is useful for searching purpose. There are many more uses of this command that you can know by hitting command 'man grep' in your unix/linux based operating system's terminal(you can call it as cmd prmpt in terms of windows).

shutdown is a command in unix that is useful for letting your system down. You can shutdown your machine immediately or after a specified time..

shutdown -t 2

Above command will shutdown the system securely after 2 seconds.

shutdown -r

Above command will reboot your machine securely..

shutdown -c

Above command will cancel shutdown job that is already running..

As specified above there are many more uses of this command that u can get to know by hitting 'man shutdown' in your terminal..

Will specify some more in next post...

Friday, December 23, 2011

Second session of Some of basic UNIX commands that are useful very frequently


Hi Folks,

In this i want to share some other UNIX/LINUX command which is useful for us very frequently.

To display list of files,directories that are available in current directly please run below command.

'ls'

If you want to see more options that are available for this command then you can run below command

ls -a - This option is used to display hidden files along with normal files.

ls -l - This option displays full details of all files and folders present in current directory. For example see below sample output of this command.

drwxr-xr-x 2 user group 4096 2011-01-06 12:06 Public
In this output, highlighted part consists total 10 fields which includes of below information:
d - means its a directory.(If it is file then this will be blank).
r - read permission for user,group,others.
w - write permission for user,group,others.
x - execute permission for user,group,others.
So, first 'rwx' means this file has all permissions for user. Next 'r-x' means this file has only read and execute permissions for group. Next 'r-x' means this file has only read and execute permissions for others.

ls -d */ - This option shows only folders present in current directory.

ls -s - This option shows files and folders present in current directory along with their sizes in blocks.

ls -lt - This option shows files in the order of their last modified time.

pwd - This option shows present working directory.

Please try these when you are free. In our next session we can discuss some other commands.

Thursday, December 22, 2011

First session of Some of basic UNIX commands that are useful very frequently


Hi Folks,

In this blog i want to discuss some of basic unix/linux commands that are useful very frequently.

If you want to display total,used and free RAM of your machine in size of MB then run below command.

free -m

If you want to see more options that are available for this command then you can run below command

man free

Some of useful options in free command:

free -t - This option will also displays data containing the totals for physical memory and swap space along with RAM.

free -ms 5 - This option i.e. '-s' followed by an integer will display commands output i.e. total,used and free RAM in MB available in your machine for every 5 seconds.

watch free - Usage of this command is same as above but in an interval of 2 seconds. When you time this command and then press enter then a new screen will be opened and automatically refresh total,used and free available of RAM in KBs. If you press 'CTRL + C' then newly opened screen will be closed and you will be returned to your command ran screen.

watch -n 1 -d free - This is can be taken as advanced version of above command. Here '-d' option is for highlighting the changes in memory usage and '-n' is for interval. For example in this command '1' is followed by '-n' so, for every one second its going to display RAM usage in KB as we didn't mention '-m' option.

Please try these when you are free. In our next session we can discuss some other commands.

Saturday, December 3, 2011

Some Of Basic FAQ about Core JAVA


Hi Friends,

In this blog i want to share some of basic FAQ about Core JAVA that may help you have some basic information.

  1. Can multiple inheritance be achieved in Java. If yes, how?
    Answer – Yes, through implementing interfaces as we can implemente multile interfaces in a single class.
  2. What is the basic difference between String and StringBuffer object?
    Answer - String is an immutable object. StringBuffer is a mutable object.
  3. What is the base class for Error and Exception?
    Answer – Throwable is base class for Exception.
  4. What is a static block?
    Answer – this is the block executed before the class initialization.
  5. Can static methods call directly non static methods of the same class?
    Answer – No. They cannot directly call. If they need, they will have to create object.
  6. From an overridden method of the sub class, how can you call the overridden base class method ?
    Answer – call the method by using 'super' keyword.
  7. Can protected methods be accessed by classes in different package.
    Answer – Yes, provided they are subclasses. Otherwise no.
  8. Can a subclass reference hold a superclass object.
    Eg: Class A, Class B.
    If B extends A. Can we say B b = new A()
    Answer – No. Viceversa is true (if A a = new B() is fine).
  9. If a super class method is throwing an IOException, what should the overriding sub class method throw?
    Answer – It should either
    Throw the same IOException
    Throw a sub class of IOException.
    Throw nothing
  10. What are the two ways of making a class non-extensible?
    Make the class Final
    Make the constructor private

Saturday, June 4, 2011

Brief uses and advantages of java.util.Arrays


Hi Folks,

In this post i want to introduce you guys about one common utility class that is very helpful in sorting and searching of values in an array of any type like int,long,String etc. Simply we can state it as java.util.Arrays which is very useful in manipulating arrays such as searching,sorting and viewing all values as a list at a time without any iteration etc.

This class contains various methods to manipulate arrays of any type. For example, you have an array of string values like below

String s[] = {"hi", "ramu", "cris"};

and you want to sort these values then you don't need to write/implement any sorting algorithm instead you can simply use statement

Arrays.sort(s[]);

to sort those values. This java.util.Arrays.sort(Object[] a) method is useful to sort array of objects. Here our s[] is String type of object so we can simply use this method to sort our array.

If you want to print all the values using at a time then also you don'e need to iterate instead you can use

System.out.println(Arrays.asList(s[]);

This method java.util.Arrays.asList(T... a) is used to back the values to a List.

Like these there are many more methods by which you can easily manipulate arrays.

Thursday, May 19, 2011

Hibernate With Examples: Hibernate Hello World Program


In this post i want to give some reference which is intuitive for beginners.

Hibernate With Examples: Hibernate Hello World Program

Friday, March 19, 2010

Brief About InvalidClassException in Java


Hi Folks,

How are you all? Today i have a got an error below which stop me to work for a couple of hours

Unable to de-serialize job. Blah.... local class incompatible: stream classdesc serialVersionUID = -9148880418277643823, local class serialVersionUID = 2323422343
java.io.InvalidClassException: ClassName local class incompatible: stream classdesc serialVersionUID = -9148880418277643823, local class serialVersionUID = 2323422343

I thought most of the folks facing this error some time and start searching google for solution. Then i also thought i share a light of my work around here.

Generally InvalidClassException comes when your class implements Serializable interface and you didn't mention serialVersionUID field in your class. If your class doen't contain this field when ever your class compiles, compiler generates a unique id like roll no which causes conflicts with old one results exception.

To avoid this problem, solution is very simple. You need to enter below field in your class when it extends Serializable interface.

public static final long serialVersionUID = 34354354435l;

This small filed eliminates problem causing InvalidClassException

When you are programming your java code in Eclipse then you get a warning like "The serializable class FlattenAllWorkingSetsJob does not declare a static final serialVersionUID field
of type long" this. If you try to eliminate that warning that automatically resolves problem of causing InvalidClassException

Saturday, December 27, 2008

Important Links For Technical


You can just know brief explanation about lisp language by the below link:

http://girnartech.blogspot.com/2008/12/lisp-tutorial-1.html

You can just know how to format pen drive in ubuntu using the below link:

http://girnartech.blogspot.com/2008/12/how-format-pen-drive-in-ubuntu.html

You can know how to install ftp server in ubuntu which will be useful for every one to connect to your system and make your system as server using the below link

http://girnartech.blogspot.com/2008/12/installing-ftp-server-in-ubuntu.html

Saturday, November 8, 2008

Part2-MVC Layer


Business Logic:

Business logic mainly describes actual logic of your software going to impliment. It means for example if you want to design a desktop search software using java then for it business logic is as follows:
  • First you need to manipulate the incoming data from the database ,in that you need to develop some logic .
  • To make another developer's way to read your logic very easily business logic helps very most.
There is also some other point which describes the business logic perfectly i.e. In sigle tier architecture if you want to write your software of desktop search then all your software code comes in single file which makes another developer difficult to modify your code because everything comes in single file i.e GUI ,Business Logic and retrieving from database etc. When you see multi-tier architecture in which every thing is divided into separa module so,anyone can understand it very clearly and modify it where ever they want.