Tuesday, September 4, 2012

Terminal customization of syntax using .exrc files

create .exrc named file only in home directory and add the following codes to it and save

set autoindent
set edcompatible
set errorbells    
"set modeline         # reduces the confusion factor immeasurably
"set nomore           # i don't want to see all the verbose error messages
set number
set remap
set report=1
set ruler
set scroll=15
set shiftwidth=2
"set showcmd          # not portable across all kinds of vi
set showmatch
set showmode 
set tabstop=2  
set ts=2
set terse
set nowrapscan
set directory=/tmp

Wednesday, August 15, 2012

Setting Class path for the Java classes(jar packages) in java environment using terminal

installing and downloading junit.jar file
1. download junit-4.10.jar file
2. copy the jar file to the location /usr/share/java/
3. now open a terminal and type to change to your user directory


4. now find the location of .bashrc file

          locate .bashrc

   it may display 3 or 4 results, out of it choose only '.bashrc' file in the user home directory
5. after locating it, open the .bashrc file

          vim .bashrc

6. now add the current line to your file  and save and exit from the terminal

          export CLASSPATH=$CLASSPATH:/usr/share/java/junit-4.10.jar;.;
          export JUNIT_HOME=/usr/share/java

          export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit-4.10.jar;.;

7. to check whether path is set, open a terminal and  type

          echo $ CLASSPATH

    it displays the result as below


8. u can also verify it by typing in the terminal
          java junit.textui.TestRunner
   the above command display like below
          Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class
   or if it display like below, then path is not set properly

          Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/TestRunner
           Caused by: java.lang.ClassNotFoundException: junit.textui.TestRunner
              at Method)
              at java.lang.ClassLoader.loadClass(
              at sun.misc.Launcher$AppClassLoader.loadClass(
              at java.lang.ClassLoader.loadClass(
           Could not find the main class: junit.textui.TestRunner.  Program will exit.

Setting path for java variable in terminal environment

installing and downloading sun java package
1. download the package jdk-6u29-linux-i586.bin
2. type the following to extract

        sh jdk-6u29-linux-i586.bin

   which will extract it in the current directory
3. Move extracted folder to the location /usr/lib/jvm

        sudo mv jdk1.7.0_ /usr/lib/jvm/

4.Inform Linux/ubuntu that new java source is available by typing (instead of editing in .bashrc file)

        sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_/bin/javac 1

  this installs the javac compiler and for the java interpreter type the below one

        sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_/bin/java 1

5. now after installing configures required for it type

        sudo update-alternatives --config javac

        sudo update-alternatives --config java

Thursday, August 9, 2012

how to introduce new variable, add path to script in linux environments using a console

adding a new path in console,

export  PATH=$PATH:/home/commands

this command with append the new path /home/commands to the environment, where, the console program check in the newly path for the commands, if commands are not found in the exsisting paths.

adding a new variable in console,

export  cd=/home/jai

 this creates a new variable next with value /home/jai . when cd is used along with the newly defined variable, it changes current directory to one /home/jai . 

cd $next
this  one changes the current directory to new one.

keyword/in-built console variable is used along with others because it make it possible to introduce a new variable or define paths at every time when the console open, hence export declares the definitions as global declarations

How to extract a bin file within linux using terminal

copy the bin file to the location u want.

 cp  /path/filenam.bin  /path_u_want/

now after copied , change into the directory. Two ways to extract bin files.
firstly,  type 

sh  filenam.bin  

the filenam.bin(binary file) is extracted.

change the permission of bin files by typing 

chmod -c 777 filenam.bin 

now run the bin file by typing



this will extract the binary files into a folder with name of binary file.

Setting path for new script file from an package within console

here, path for a script file within an extracted folder are set, without editing .bashrc file. u can choose any path for ur script file.

now for installing or for introducing the script file to console environment, type

sudo update-alternatives --install /usr/bin/scriptfilenam scriptfilenam /path/scriptfilenam

scriptfilenam - name of script file,  path - path of script file(eg: /home/play-2.0.2/)
" update-alternatives  - maintain symbolic links determining default commands
   update-alternatives creates, removes, maintains and  displays information  about  the symbolic links comprising the Debian alternatives system. "
says the manual page for update-alternatives.

install option , adds the alternative link of script file to the console environment.
now again type

sudo update-alternatives --config scriptfilenam

 which configures  this file.

hence, new scripts path is set. check it by typing the scriptname

Thursday, February 16, 2012

Changing Mac address in linux

Firstly, type

sudo ifconfig -a | grep HWaddr
to find the mac address of your system .ie, you will get the output as below :

eth0      Link encap:Ethernet  HWaddr b0:f3:29:68:a6:0c 

wlan0     Link encap:Ethernet  HWaddr 11:00:22:a3:g4:20 

 where the eth0 is the address for wired lan and wlan0 for wireless ie wifi.
 Now to change the mac address, type the following

ifconfig eth0 down
ifconfig eth0 hw ether 11:20:48:BA:d1:30 
you can choose the mac id you want, i.e. 11:20:48:BA:d1:30
ifconfig eth0 up
ifconfig eth0 |grep HWaddr
Now the mac address is changed, but it is temporary one. If u reboot, you can see ur original mac id.
The mac address is burned into your lan and it can't be changed permanently.