Operations 10 min read

Master Linux File Compression: tar, gzip, bzip2, 7zip and More

This guide explains why file compression matters for storage and bandwidth, then details the most common Linux compression utilities—including tar, gzip, lzma, xz, bzip2, pax, peazip, 7zip, shar, cpio, ar, iso, kgb, zpaq, and File Roller—along with installation steps, key options, and practical command examples.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux File Compression: tar, gzip, bzip2, 7zip and More

Why Compress Files?

Compressing files reduces disk usage and can dramatically lower network bandwidth consumption when transferring data. Below is a practical reference of common Linux compression tools.

1. tar

tar is the most popular archiving tool on Linux, supporting gzip, bzip2, lzma, etc.

Installation

apt-get install tar
yum install tar

Example

fallocate -l 512M um.img
tar -cvfz um.tar.gz um.img
-c

– create archive -v – verbose output -f – specify archive file -z – compress with gzip

2. gzip

gzip is a fast, widely used compressor that keeps the original filename and adds a .gz extension.

Installation

apt-get install gzip
yum install gzip

Example

gzip examplefile
gzip -l examplefile.gz
gzip -d examplefile.gz
gzip -r examplefile

3. lzma

lzma offers faster compression than bzip2 and is built into most Linux distributions.

Example

lzma -c --stdout examplefile > examplefile.lzma
lzma -d --stdout examplefile.lzma > examplefile

4. xz

xz is the successor of lzma; it compresses single files and automatically adds a .xz extension.

Example

xz examplefile
xz -d examplefile.xz

5. bzip2

bzip2 provides tighter compression than gzip but requires more RAM; use -s for low‑memory mode.

Example

bzip2 examplefile
bzip2 -s examplefile
bzip2 -v examplefile
bzip2 -d examplefile.bz2
bunzip2 examplefile.bz2

6. pax

pax is a fast, versatile archiver that can also copy files remotely.

Installation apt-get install pax Example

# pax -wf examplefile.tar examplefile
# pax -wf examplefile.tar.gz examplefile
pax -f examplefile.tar
pax -r < examplefile.tar

7. Peazip

Peazip is a cross‑platform GUI front‑end based on 7zip, supporting over 180 formats.

Installation

wget sourceforge.net/projects/peazip/files/1/peazip_LINUX.Qt-2_i3deb
dpkg -i peazip_LINUX.Qt-2_i3deb

8. 7zip

7zip is an open‑source compressor known for high compression ratios.

Installation apt-get install p7zip-full p7zip-rar Example

7z a examplefile.7z examplefile
7z e examplefile.7z

9. shar

shar creates simple shell archives useful for bundling scripts.

Installation apt-get install sharutils Example

shar examplefile > examplefile.shar
unshar examplefile.shar

10. cpio

cpio reads a list of filenames from stdin and creates an archive; it requires no installation.

Example

cd /tmp
ls | cpio -ov > /home/username/backup.cpio
cpio -idv < backup.cpio

11. ar

ar is the ancestor of the RAR format, still used on Debian‑based systems.

Example

ar cvsr examplefile.a examplefile
ar -xv examplefile.a

12. ISO (dd)

Use dd to create an ISO image from a DVD or other media.

dd if=/media/dvd of=/home/username/filename.iso

13. kgb

kgb is a lesser‑known archiver that achieves high compression ratios.

Installation apt-get install kgb Example

kgb examplefile.kgb examplefile
kgb x examplefile.kgb

14. zpaq

zpaq handles large files with a lightweight implementation of the PAQ context‑mixing algorithm.

Installation apt-get install zpaq Example

zpaq c examplefile.tar examplefile

15. File Roller

File Roller is a GUI archive manager for Linux, supporting formats such as .iso, .7z, .gz, .zip, .bz2, etc.

File Roller UI
File Roller UI
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxGzipcompressioncommand-linetar
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.