Wednesday, September 9, 2009

The hint of extracting tarball

I created a directory called, file. Then, i touched 3 dummy files, file1, file2, file3.

[root@rhel54-1 file]# ls
file1 file2 file3

when i zip those file. I choose two different ways, one with gzip compression and one without

[root@rhel54-1 ~]# tar -cvf file.tar.gz file/
file/
file/file2
file/file3
file/file1


[root@rhel54-1 ~]# tar -zcvf file.tgz file
file/
file/file2
file/file3
file/file1

[root@rhel54-1 ~]# tar -jcvf file.tar file
file/
file/file2
file/file3
file/file1


I have three tarball files right now. Then, I do a file command on my tarballs file

[root@rhel54-1 ~]# file file.tar.gz
file.tar.gz: POSIX tar archive

[root@rhel54-1 ~]# file file.tgz
file.tgz: gzip compressed data, from Unix, last modified: Thu Sep 10 10:27:48 2009

[root@rhel54-1 ~]# file file.tar
file.tar: bzip2 compressed data, block size = 900k

Cool. I have three different formats. POSIX tar archive, and gzip and bzip2 file.

So, when i extract the tarballs. i will prompt in the command.
1. tar -zvxf for gzip tarball
2. tar -xvf for POSIX tar archive
3. tar -jvxf for bzip2 tarball

Obviously, the size of those tarballs also varying.

[root@rhel54-1 ~]# ls -sh file.*
4.0K file.tar 12K file.tar.gz 4.0K file.tgz

gzip and bzip2 is much more better than POSIX tarball.

No comments: