Linux: Compression How-to: tar gzip bzip2 xz 7zip rar zip

,

This page shows you how to compress/decompress many formats on Linux.

Here's a summary of which to choose:

tar archive (.tar)

“tar” is unix/linux standard for archiving a folder. It doesn't compress. To be used together with gzip or other. File extention: “.tar”.

The “x” is for “eXtract”, “v” = “verbose”, meaning print out status. “f” = file. “c” = create.

“tar” program can untar/decompress in one step:

gzip compression (.gz)

gzip is Linux standard for compressing a single file. Classic. Most widely used. Usually used together with tar. File extention: “.gz”.

bzip2 compression (.bz2)

Alternative to gzip, for compressing a single file. File size smaller than gzip. File extention: “.bz2”.

xz compression (.xz)

Alternative to gzip, for compressing a single file. File size smaller than bzip2. xz is derived from 7-zip. File extention: “.xz”.

Here's size comparison:

emacs-24.2.tar.gz  49M
emacs-24.2.tar.bz2 40M
emacs-24.2.tar.xz  33M

zip archive (.zip)

ZIP (file format) is for archiving and compressing a folder or single file. Originally from Windows world. File extention: “.zip”.

7-zip archive (.7z)

7-zip is for archiving and compressing a folder (similar to zip). Originally from Windows world. Compresses the best. File extention: “.7z”.

The 7z util can decompress many formats.

rar archive (.rar .rev .r00 .r01 .r02 …)

RAR (file format) is proprietary, from Windows world. Often used for pirated videos. File extention: {.rar .rev .r00 .r01 .r02 …}.

To extract rar files, use 7z e filename.

blog comments powered by Disqus