Posted by: kezhong | June 23, 2009

Linux File Archive and Compression Tools

Many new Linux users confuse the archive and compression files. They don’t understand what are the files with extension .tar, .gz, .bz2, .tgz, .tbz2 and so on. And they don’t know what the difference between them.

Archive is combining a number of files together into one file. The popular archive file formats are tar on Linux and Unix systems. On the other hand, compression is the process of using encoding schemes to store information in fewer bits. The popular compression formats are gz, and bz2.

.tar
The file with .tar filename extension means the archive file created by tar utility. And it is not compressed file. For examples:
To create an archive file for a directory
            $ tar cvf joker.tar dir1/
To extract a tar archive file
            $ tar xvf joker.tar

.gz
The file with .gz filename extension means the file using the gzip utility to compress. For examples:
To compress a file, remove it, and produce a new compressed file which filename extension is .gz
            $ gzip file1
To decompress a file compressed by gzip utility
            $ gunzip file1.gz          or         $ gzip –d file1.gz 

.bz2 or .bz
The file with .bz2 or .bz filename extension means the file using the bzip2 utility to compress. For examples:
To compress a file, remove it, and produce a new compressed file which filename extension is .bz2 (or .bz)
            $ bzip2 file1
To decompress a file compressed by bzip2 utility
            $ bunzip2 file1.bz2      or         $ bzip2 –d file1.bz2 

.tar.gz or . tgz
The file with .tar.gz or .tgz filename extension means the file using gzip utility to compress a tarball. For examples:
The first way to produce a .tar.gz file
            $ tar cvf joker.tar dir1/
            $ gzip joker.tar
The second way to produce a .tar.gz file
            $ tar cvfz joker.tar dir1/
The first way to decompress and extract a .tar.gz file
            $ gunzip joker.tar.gz
            $ tar xvf joker.tar
The second way
            $ tar xvfz joker.tar.gz

.tar.bz2 or .tbz2
The file with .tar.bz2 or .tbz2 filename extension means the file using bzip2 utility to compress a tarball. For examples:
The first way to produce a .tar.bz2 file
            $ tar cvf joker.tar dir1/
            $ bzip2 joker.tar
The second way to produce a .tar.bz2 file
            $ tar cvfj joker.tar.bz2 dir1/
The first way to decompress and extract a .tar.bz2 file
            $ bunzip2 joker.tar.bz2
            $ tar xvf joker.tar
The second way
            $ tar xvfj joker.tar.bz2 

 

Reference
File compression tools for Linux


Responses

  1. […] Read more:  Linux File Archive and Compression Tools « Kezhong's Weblog […]

  2. […] https://kezhong.wordpress.com/2009/06/23/linux-file-archive-and-compression-tools/ […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: