Wednesday, March 7, 2012

Usage of tar (file format) command in unix

tar(file format)

It is commonly used to collect many files into one larger file for distribution or archiving, while preserving file system information such as user and group permissions, dates, and directory structures.


Basic tar command only involve 5 options c, z, f, v, x
 
c = create a new tar file
v = verbose , display file to compress or uncompress
f = create the tar file with filename provided as the argument
z = use gzip to zip it
x = extract file


1) Compress / zip it with command tar -cvzf tarname.tar.gz folder
For example i want to compress and tar a folder name “abc”.

$ tar -cvzf abc.tar.gz abc
 
2) UnCompress it / unzip it with command tar -xzvf tarname.tar.gz
uncompress it or unzip abc.tar.gz.

$ tar -xvzf abc.tar.gz

No comments: