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

By Xah Lee. Date: . Last updated: .

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 standard for archiving a folder. It does not compress.

Here's what the option means:

“tar” can untar and decompress in one step:

gzip compression (.gz)

gzip is unix standard for compressing a single file. gzip is often used together with tar.

bzip2 compression (.bz2)

Alternative to gzip, for compressing a single file. File size smaller than gzip.

xz compression (.xz)

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

zip archive (.zip)

ZIP (file format) is for archiving and compressing a folder or single file. Originally from Windows world.

7-zip archive (.7z)

7-zip is for archiving and compressing a folder (similar to zip). Originally from Windows world. Compresses the best.

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 extension: {.rar .rev .r00 .r01 .r02 …}.

To extract rar files, use 7z e filename.

Compression File Size Comparison