UNIX‎ > ‎

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.

  1. Check the filessize after combining
  2. check the transferred file is same size as source
        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 Widgets

If 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.


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}'
Good link for Date formats in Unix/SHELL program which you need regularly.




Dec 11, 2008, 5:17 AM