Thursday, February 23, 2006

All about compression on Unix/Linux

Often you would want to compress or uncompress files when you want to move it from one machine to another. This reduces the time it takes to copy the file over the network. I have added below most of the compression methods I am familiar with and will be adding more as I learn of them...please feel free to add in your own replies!

Using tar files

Tar files dont actually compress anything. They just bundle up files into one Tape ARchive. Which is why you generally see that tar files also zipped with gzip.

To create a tar file:
#tar -cvf .tar
Note: The extension needs to be specified. The target can be a wildcard or a directory.

To unroll a tar file:
#tar -xvf
Note: You might want to run tar with the -tvf switch to see what the file contains before extracting.

To create a zipped tar file (using gzip):
#tar -zcvf .tar.gz

To untar and to uncompress a tar file in one command (valid for gzipped files):
#tar -zxvf
----------------------------------------------------------------------------------------------------------------------
Oh and by the way, to confirm that the file you are copying is correctly copied to the target machine, u can you the "sum" command which prints out the checksum for the file.

#sum

The checksum should be identical with the source machine.

PS: If you are using Windows, I dont think you will have a checksum utility (??). I would suggest you install cygwin which provides windows versions of all the common Unix commands.

\\fileserver\public\software\windows\X-Servers\setup.exe


or

http://www.cygwin.com/

No comments: