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.