الجمعة، 28 مايو 2010

How to create archives and compress file in Linux

With Linux default environment, tar is come by default and you may easily archives and compress a file or folder easily by using tar command.
If you familiar with Linux, you should know that file could be archives to .tar, .tar.gz, .tgz, .bz2, .tgz, etc, but do you know how to archives it and how to remember and understand it? It is pretty easy, actually.
To archives each of the folder/file, you may refer to the step as below.
.tar -> tar -cf file.tar folder/ # c indicate that you are creating a file and f is use to force create the inheritance file from the folder.
.tar.gz -> tar -zcf file.tar.gz folder/ # z indicate that you are using .tar.gz or tgz extension
.tgz -> tar -zcf file.tgz folder/
.bz2 -> tar -jcf file.bz2 folder/ # bz2 is a type of archives that using lesser space and it required option j.
.gz -> gzip file.gz folder/ # gzip use to zip and remove the original file.
.zip -> zip -r folder.zip folder/ # zip is another archives type that not using tar but it is useful for Windows Operating System.
To extract the file as above, simply change all c to x.
.tar -> tar -xf file.tar
.tar.gz -> tar -zxf file.tar.gz
.tgz -> tar -zxf file.tgz
.bz2 -> tar -jxf file.bz2
.gz -> gunzip file.gz
.zip -> unzip folder.zip

ليست هناك تعليقات:

إرسال تعليق