About Me

My photo
Working as Technical Lead in CollabNET software private limited.

Tuesday, 26 February 2008

To split and analyze the log files.

When ever the log file size is more, Try splitting it and view the file!

Calculate the length of the log file

wc -l log-file.log

Then split the file based on the total number of lines.
For ex Consider the no of lines as 1000, then we can split in to files of 100 lines using below command.

split -l100 log-file.log log-file.log.

This will result in multiple files of 100 lines each. The name of files would be appended by aa,ab,....

To rejoin the file use below command

$ cat log-file.log.* >lastweek.mp3

What for /dev/null?

Do you know why they redirect to /dev/null

/dev/null or the null device is a special file that discards all data written to it

The null device is typically used for disposing of unwanted output streams of a process. It's equivalent to "don't bother about the results ".

ex:

ls -l *.txt > name.txt 2>/dev/null

Monday, 25 February 2008

Consecutive commands in linux

Adding && between the commands works!

Command1 && Command2

Some times we would be pasting the command in vim with out a directory. I think this will be more helpful to append before the command instead of removing and pasting another time.

mkdir DIST && command

Debug Java Application or Java Web Application using Eclipse

Steps To Configure Java Application with eclipse

1. Append below parameters to JVM_ARGUMENTS of the Application

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,
address=5050


2. Configure your Eclipse Debugger.

Go to project source.
Place Break Points in Project source where ever needed.
Go to Project > Run > Open Debug Dialog
Create new Remote Java Application with corresponding parameter
Host - Application Host IP
Port - Port specified in JVM_ARGUMENTS of Application.
Click Debug

3. Access your application.

Friday, 22 February 2008

Basic X11 Forwarding Over SSH

X11Forwarding needs to be enabled on the sshd server. Do this by making the following edit:
File: /etc/ssh/sshd_config

After you make these changes, you will need to restart sshd so the changes will be accepted:
/etc/init.d/sshd restart

Don't forget to log out and log in to the server for this change to take effect.

Note: one reason for receiving the error messages

xterm Xt error: Can't open display: your_client_name:0.0

may be that X11Forwarding is not enabled on the server.
[edit] Running single apps

$ ssh -X < remote_server >

Thursday, 21 February 2008

Needed shell script to compile and run java files.

#Let's start building the classpath with existing jars & libs.
THE_CLASSPATH=
for i in `ls *.jar`
do
THE_CLASSPATH=${THE_CLASSPATH}:${i}
done

# Let's compile all the java file.

for i in `find . -name '*.java'`
do
echo "Compiling $i"
javac -cp $THE_CLASSPATH $i
done

# invoke the main function.

java -cp .:$THE_CLASSPATH $CLASSNAME$
unset THE_CLASSPATH

To set classpath in linux

Simple tips, tought it will be useful

CLASSPATH=*.class:$CLASSPATH
export CLASSPATH

Wednesday, 20 February 2008

To open mutiple files in vi

vi -o file1 file2

To switch between splitted windows use

< ctrl >+ w

To Quit all qa!
To save all wa!
To save&quit wqa!

Tuesday, 19 February 2008

Diff and Patch

I Recently came across two more useful linux commands diff and patch. :)

DIFF:
Display the differences between two files, or each corresponding file in two directories.
SYNTAX
diff [options] from-file to-file > path-file-name

PATCH
SYNTAX
patch -p0 < new-patch
patch -p1 < new-patch
Levels in the Patch Command (-p0 or -p1?):
The -p option will optionally strip off directory levels from the patchfile. For Ex: if you have a patchfile with a header as such:

--- old/modules/pcitable Mon Sep 27 11:03:56 1999
+++ new/modules/pcitable Tue Dec 19 20:05:41 2000

Using a -p0 will expect, from your current working directory, to find a subdirectory called "new", then "modules" below that, then the "pcitable" file below that.

Using a -p1 will strip off the 1st level from the path and will expect to find (from your current working directory) a directory called "modules", then a file called "pcitable". Patch will ignore the "new" directory mentioned in the header of the patchfile.

For more Info:
man diff/patch

To Reset Firefox MasterPassword

Firefox:

Enter "chrome://pippki/content/resetpassword.xul" in the Location Bar, press Enter, then click "Reset"