Monday, December 2, 2013

Eclipse/STS IDE shortcuts

Hi Friends,

After a long gap i.e. near about a year, today I want to blog some of the useful shortcuts that will help us in coding any program using IDEs such as Eclipse and STS (Spring Source Tool Suite).

Its suggested that any java beginner programmer to use notepad/notepad++ as editor to start their coding. However IDEs like Eclipse and STS will increase speed of programming as they are built with lot of shortcuts. Today we are going to discuss some of the very useful shortcuts those will increase our speed of programming.

As STS is built up on Eclipse IDE, most of shortcuts that I explain in this blog are common for both editors.

File Navigation

 CTRL + SHIFT + R - To open a resource (any file like .java, .jsp etc) in the projects present in current workspace of IDE.

CTRL + PAGE UP or PAGE DOWN - Nagivate to previous or next file from within the list of all open files.

CTRL + E - To display all open file list.

ALT LEFT ARROW (<-- alt="" arrow="" or="" right="">) - Navigate to previous or next edit positions from edit history.

Editing shortcuts


CTRL + SPACE - Type assist (For ex: if you type Str and then presse ctrl + space in some x.java file then it will show all available options like java.lang.String class etc. to complete your choice without typing full word)

CTRL + SHIFT + F - Will format the code according to the preferences set in IDE. You can change format preference by navigating to 'preferences' section of IDE.

CTRL + O - Will show list of methods (including inherited) of class (For ex: In X.java you have methods names x(), y(), z() and you pressed ctrl + o in that file then it will show all three methods)

CTRL + SHIFT + O - Will organize your class imports section. It will automatically remove/add any unused/required imports to fix import compile errors.

CTRL + SHIFT + C - Will comment selected lines (like // before starting of each line).

CTRL + SHIFT + / - Will comment selected lines as a block comment (like /* .. */).

CTRL + SHIFT + \ - Will uncomment selected commented block.


When you are free, don't hesitate to try these and post your feedback. Will discuss about some more useful shortcuts in next posts.

Tuesday, November 27, 2012

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


In todays session, we will discuss about some more useful commands which are used frequently in UNIX/LINUX based Operating Systems.

df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown. Disk space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

As described in previous post, you can get the value of environment variable POSIXLY_CORRECT by echo command.

df filename.jpg

As depicted, above command will shows disk space available on the file system containing 'filename.jpg'. Below is output:

sanny@sanny-Inspiron-3420:~/Desktop$ df filename.jpg
Filesystem    1K-blocks       Used     Available   Use%   Mounted on
/dev/sda6    171485500     3372236  159402232         3%        /


There are some common features available which are used for I/O Redirection.

'<' Input Redirection. This allows one to take input from file rather than standard input (stdin) taken from console.

Ex: tr a x < filename

'>' Output Redirection. This allows one to take output to file rather than standard output (stdout) printed to console.

Ex: ls -a > filename

'|' Pipe This allows one to take one command's output to another commands input.

Ex: ls -a | more

When you are free, dont hesitate to try these and post your feedback. Will discuss about some more useful commands in next posts.



Thursday, October 18, 2012

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


Today we will discuss about some more commands that are used very frequently in UNIX/LINUX bases operating systems.

If one want to print value of 'PATH' system variable, then using below command we can achieve it.

echo $PATH$

Above command will displays the value of system variable 'PATH'. Its similar to the below command that we use in windows based operating systems.

echo %PATH%

Below is sample output:

$ echo $PATH$
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)....


Like wise, if one want to display value of any system variable or user defined system variable like JAVA_HOME, CLASSPATH and CATALINA_HOME etc.., then he/she can achieve it as specified above.

To confirm what you are thinking in your mind to execute the same, below is one more similar example for displaying value of 'JAVA_HOME' ( one can also say that Java installed directory):

echo $JAVA_HOME$

Hmmmmmmmm...... yes, your thought is correct. Its similar to echo %JAVA_HOME% that we use in windows based operating systems to know Java installed directory.

If the variable that you want to know the value is not set in your system, then you will get result as an empty string ''. Below is sample illustration:

$ echo $JAVA_HOME$
$


Please feel free to try this. If you already got a chance to work with, then share your thoughts....

Can guess your next thought??????? to modify corresponding system variable (PATH, JAVA_HOME etc..).. how it can be achievable??? Don't worry, we can discuss about this in next post.. will keep posting...

Wednesday, October 17, 2012

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


Today we will discuss about some more commands that are used very frequently in UNIX/LINUX based systems.

echo is a command used to print any argument that we give. Basically this command is very useful when one want to write shell script(.sh) like batch script(.bat) that we used to write in Windows based systems.

echo argument

Above command will display 'argument' in the terminal. So, while writing shell script and want to debug/log user given argument then, we use this. Its similar to 'System.out.println' that we use in Java to print some thing.

file is a command used to determine type of file by examining its content.

file .bash_profile

Above command will display classification of file named '.bash_profile' present in home directory i.e. /home/ by examining its content. Below is its output:

$ file .bash_profile
.bash_profile: ASCII text


head is a command used to display first few lines of file specified as an argument.

head filename

Above command will display first few lines of a file named 'filename' present in current working directory. Below is output of head command executed on file named 'terimerilyrics':

$ head terimerisonglyrics
Aa......

Teri meri, meri teri prem kahani hai mushqil
Do lafzoon mein yeh bayaan na ho paaye
Ik ladka ik ladki ki yeh kahani hai nayi
Do lafzoon mein yeh bayaan na ho paaye

Teri meri, meri teri prem kahani hai mushqil
Do lafzon mein yeh bayaan na ho paaye
Ik dooje se huey juda Jab ik dooje ke liye bane


As conveyed in previous posts, don't hesitate to try these commands. We will discuss about some more useful commands in next posts.

Tuesday, October 16, 2012

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


Today we will discuss about some more useful commands that are frequently used in UNIX/LINUX based systems.

wc is a command by which one can know about no of lines, words and characters present in a file.

wc filename

Above command will gives number of lines, words and characters present in file named 'filename' present in current working directory. You can know current working directory by using pwd that we discussed in previous posts.

date is a command which displays current date and time.

diff is a command using which you can find differences between two files. It displays differences between two files by comparing each other.

diff filename1 filename2

Above command will show all differences between files named 'filename1 and filename2'present in current working directory.

du is a command by which one can know disk usage i.e. space used by directory and its contents.

Don't hesitate to try these when you are free. If you already got a chance to try these, feel free to give your valuable feedback/comments. We will discuss about some more useful commands in next posts.

Saturday, September 29, 2012

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


Today we will discuss about some more useful commands in UNIX/LINUX based operating systems.

Top is a command used to display and update information like PID, username, cpu, and time etc. about top CPU processes. By default, it displays about top 30 processes and periodically update information about them. Its some what like task manager in WINDOWS based systems where processes tab will dynamically update information about process like how much memory and cpu consumed... Below is sample snapshot of top command in UNIX.




As shown above it displays information and update it periodically of top running processes. If you want to kill any process, then you can simply press 'k' and then corresponding PID of the process. If you want to come back to your terminal, you can simply press 'q' to quit from top command i.e. displaying and updating information about top running processes. You can see the video which explains very clearly usage of this command.

One more important command that we are discussing today is su command which is very useful in executing any commands with respect to another user. It creates a shell(new terminal)with the user id of another user.

su root

Above command will opens a new shell(like new cmd prompt) with 'root' user which is real administrator in UNIX based systems. As UNIX is very secured, for some operations to execute, you need to be real administrator. In such cases this command will be very useful.

This command has many more uses that you can know by using 'man su' as we described in previous posts...

Will discuss about some more useful commands in UNIX/LINUX systems in next posts. Please feel free to post any suggestions/queries.


Wednesday, September 26, 2012

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


Today we are going to discuss about one more important command in UNIX/LINUX based operating system that is used to kill processes that are running currently. It is some what like Task Manager in our windows based systems where task manager can be used to view/kill processes that are running currently instead this command is used only to kill processes.

kill -9 1234

Above command will kills process with process ID(PID) '1234'. You can get to know currently running process's PIDs by using 'ps' command that we discussed in our previous post. Below is sample output that a 'ps' command will show:



In above output, IDs that are present under heading 'PID' like '2660, 5796 and 4484'are PIDs similar to '1234' in out above kill example.

In our above example command '-9' that we used to kill process is signal that we are sending to kill process. There are several signals that we can send to kill process are below:




kill 4242

Above command will kill PID 4242 and exit gracefully.

kill -s SIGKILL 1414
kill -s KILL 1414
kill -s 9 1414
kill -SIGKILL 1414
kill -KILL 1414


All above commands are similar equal to above explained first example's -9 SIGKIL (i.e. forcefully kill 1414 process).

Please feel free to post your valuable comments. We will discuss about some more commands in our next posts.


Tuesday, September 25, 2012

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


Today we will discuss about some more useful commands in UNIX/LINUX based operating system.

If you want to see quickly what is the content of a file, then you can use below command to see the content of file in the same terminal you are working currently.

cat filename

Above command will display content of file named 'filename' present in current working directory in the terminal.

cat filename > /x/y.txt

Above command will copies content of file named 'filename' present in current working directory into file named 'y.txt' present in path '/x'.

cat filename1 filename2 > /x/y.txt

Above command will concatenate content of files named 'filename1'and 'filename2' present in current working directory into file named 'y.txt' present in path '/x'.

cat filename1 filename2

Above command will concatenate content of files and displays in the terminal. It doesn't modify original files instead it display both files content into terminal by concatenating.

One more important command that we are going to discuss today is 'ps'.

ps

Above command will display current processes which are running. This command is some what like a 'Task Manager' in windows where as the difference is in task manager we can kill process which we don't want to run but, here we can know process IDs by which we can delete the process using 'kill' command that we can discuss in our next post. This command will display lot of information about processes that are currently running.

ps -u

Above command will display current processes that are running in current log-in.

Please feel free to post your comments/queries. We can discuss some more useful UNIX/LINUX commands in our next post.

Tuesday, September 18, 2012

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


Today we are going to discuss about one more useful command which will be very important in security aspect i.e. When ever you have file/folder which is very important and you don't want others to read your content then this post is very very helpful in making your content private.

chmod is a command by which you can modify permission of a file/folder according to your wish.

chmod -R 777 /home/x/y.java

Above command will give permissions to read, write and execute for the file 'y.java' present in path '/home/x' so that 'y.java' can be accessed (read, write and execute) by anyone.

In the above command main important part is 3 '7's which decide up to what level one can access corresponding file.

First digit: First '7' is used to give permissions to corresponding user. And one can assign '0-7' We can discuss what is the meaning of each digit from '0-7'.

Second digit: Second '7'is used to give permissions to group to which corresponding user belongs too. And one can assign '0-7' for this digit too.

Third digit: Third '7'is used to give permissions to others. Similar to above 2 digits one can assign '0-7' for this digit too. And you can also refer previous post which contains same explanation.

Regarding assigning '0-7' to each user/group/others please read below table for clear explanation.

# Permission rwx
7 full 111
6 read and write 110
5 read and execute 101
4 read only 100
3 write and execute 011
2 write only 010
1 execute only 001
0 none 000

So, as per above table if you don't want to give neither of read,write and execute permission to user, group and others then you can use '000' to assign permissions to corresponding file.

chmod -R 700 /home/x/y.java

Yes, as per your guess, above command will give read,write and execute permission to user and gives no permission to group and others. So, that we can restrict 'y.java' file to corresponding user only.

Like this you can use different combinations in the above table to give/restrict permissions to corresponding user, group and others.

One more important point to remember to use this command is, file to which you are going to modify permissions should be closed and you should be owner of the file. You can also get more information about this command by hitting 'man chmod' in the terminal.

Please feel free to post any help/suggestion. Will discuss some more in next posts.....

Monday, September 17, 2012

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


Today we will discuss about some more useful commands that are used very frequently when you work with UNIX/LINUX based Operating Systems.

mkdir is a command which created new directory in your file system.

mkdir NewDirectory

Above command will create new folder named 'NewDirectory' in present working directory. You can fetch your present working directory by hitting 'pwd' in your terminal. For suppose you are in directory '/home/x/y' then new directory named 'NewDirectory' will be created in ' /home/x/y'.

mkdir /x/y/z NewDirecotory

Above command will create new folder named 'NewDirecotry' in the path '/x/y/z'.

Similarly you can remove a folder and its contents by using command rmdir.

rmdir NewDirectory

Above command will deletes/removes a folder named 'NewDirectory' from current working directory. If that directory contains any sub folders/files then will confirm from user before deleting each file/folder with 'Y/N ?'. So, you can remove/delete each file/folder by pressing 'y'.

rmdir -f NewDirectory

Above command will deletes/removes 'NewDirectory' and its contents without asking confirmation to delete.

rmdir -f /home/x/y/*

Above command will deletes/removes content (files/sub folders) in the path '/home/x/y' without asking confirmation to delete. Like '*', we can use patterns to delete files. Below is small example:

rmdir -f /home/x/y/a*.java

Above command will deletes/removes files whose names starts with 'a' and extension '.java' in the path '/home/x/y/'.

Don't hesitate to try these when you are free.. If you already had a chance to try these, then don't hesitate to write your valuable comments. Will discuss some more in next post....