UNIX Tips -  2

Sponserd tips by Jawad Ahmed, and Hariprasad Badginchla

 

Situation: On the production environment having a huge size of file formed from various files located in sequence of folders, that need to transfer from Linux Box to Solaris Box. Normal ‘sftp’ command is consuming more than 2 hrs but only part of the file is transferred.

 

"Always make a backup" but in a wise way...

Disk Usage commands

Production environment is critical to perform. Every act that we perform double-check is best way.

        First find the combined file is correct or not. Verify this with

du –k  [path][.]

for Solaris boxes

 du –fk [path][.]

This will give you the size of each folder and also the sum of those folder content together.

 

If the disk usage by the files is equal to the combined file approximately same then it is fine otherwise troubleshooting the combine process.

cksum filename

num num filename

 

The first number indicates the number of blocks consumed for this file. The second number indicates the file size in bytes. Here the first number is significant because after transferring to the other boxes we need to verify the number of blocks received it should match with source side blocks.

 

 Compression commands

Amazon.com WidgetsIf the file size is very huge compress it in double time with tar and gzip commands.

 tar –cvf tarfile source-file(s)

 

This will creates the new .tar file which will be compressed, combined if the source is a folder.

 gzip tarfile

 

This Gun zip is most powerful and its ability to compress is very high it is almost comes to ¼ of the original size after compression, this will generates .gz file.

 gunzip zippedfile.gz

 

Here the gunzip command will extract the zipped file (unzip) the file content.

Both the above commands combination can be achieved with pipe as follows:

tar cvf - [sorce][.]  | gzip > ~/backup-120908.tar.gz

 

Secure copying from Linux box to Solaris Box.

scp –rf user@host:absolutepath destinationpath

-r option is for recursive properties

-f  to indicate that a file

 

Overall -rf will gives the same permissions which are assigned at source to the destination file too.

 

Another form of scp

 scp –rf sourcepath user@host:destinationAbsolutePath

 

When you are copying between the different remote machines but on to the same user then the command goes like this:

 scp –rf sourcepath @host:~/relativePath

There is no need of giving user name before @ symbol. You can use the relative path for the destinations. follow this trick save your time.

Conclusion

With my experiments found that SCP is much better in fastness than SFTP command.

The status of copying is clear with * bar shown below the scp command. It is also shows how much percentage copied to the target out of original size of the file. This will allow you to make wise decision on the transferring of the files.

  grep CLASSPATH wluser.log|awk -F":" '{for (i=1 ; i<=NF ; i++) print $i}'

http://www.pcnetcom.net/solaris.htm

 

Good link for Date formats in Unix/SHELL program which you need regularly.

 

http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/

 

http://linux.about.com/library/cmd/blcmdl1_du.htm

http://www.pcnetcom.net/solaris.htm

http://www.softpanorama.org/Solaris/solaris_tips.shtml