Sunday, March 16, 2014

Verify Checksum Of A Downloaded File

Introduction

These days, we download a lot utilities from internet. Many people don't bother to verify the contents of the file and extract them to their desktop. This kind of practice could harm the computer or your private information could be leaked to someone's hand. Thus, we should verify the file to see if it is tampered by someone or not. This article describe the one of many tools you can use to perform such a kind of activities.

Available Tools

Please visit this page for the tools available. I have been using the "File Checksum Tool" to verify MD5 checksum. It is very simple to use.

How-To-Do-It

Once you download the tool and start it, you should see the following screen:

Here is the procedures:
  1. Browse file you downloaded.
  2. Check MD5 for the checksum
  3. Calculte Hash
  4. copy the checksum and compare them.

Friday, February 7, 2014

Working MacOS Environment

vim With Syntax Hightligh

By default MacOS does not turn on the syntax highlight. In order to turn on the feature, create a file named: .vimrc and put the following contents in the file:

   filetype plugin indent on
   syntax on

Setup JAVA_HOME

In windows or linux environment, we get used to setting the JAVA_HOME environment variable and set PATH variable. That is easy because we know where is the java installation. For MacOS, the java installation is not so obvious. However, there is a way to find out where is the java installation. The command is under:

    /usr/libexec/java_home

The java_home is a binary utility. You can run it. Here is the result when I run on my macbook pro

.
   [/Users/Gary2013]$ /usr/libexec/java_home 
   /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
   [/Users/Gary2013]$ 

It is clear that I have install jdk 1.7.0_40. Now we can set the JAVA_HOME environment variable by put the following lines in our .bashrc file:

   JAVA_HOME=$(/usr/libexec/java_home) ; export JAVA_HOME
   PATH=$JAVA_HOME/bin:$PATH
The second line is important. Don't put that like the following:
   PATH=$PATH:$JAVA_HOME/bin
If you do this way, the correct java may not be used. This is because there is java under /usr/bin/java. By put the $JAVA_HOME/bin in the front, we make sure the java version is correct.

Friday, January 31, 2014

Use awk

This is handle one line to update double-quote to the beginning and end of each line of a file. And put plus sign at the end of the line. The purpose for this is that I want to copy the text file as a string to java String

 cat test.msg  | awk '{printf("\"%s\" +\n", $0);}'

Thursday, January 30, 2014

Useful Linux Commands

How To Truncate Large Files

Many times, we want to truncate some large files because of space it take. In Linux OS, you have few options. The first one will be using truncate utility.
    truncate -s 0 myLargeFile.log
The other one is:
    > myLargeFile.log
The above 2 commands are the same. But the second one cannot be used with sudo.

Rotate Log Files Using logroute Utility


A good explanation can be found here:

The Ultimate Logrotate Command Tutorial with 10 Examples

ls in Windows

echo dir %1 > %systemroot%\system32\ls.bat