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.
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 tarExample
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 gzipExample
gzip examplefile gzip -l examplefile.gz gzip -d examplefile.gz gzip -r examplefile3. 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 > examplefile4. xz
xz is the successor of lzma; it compresses single files and automatically adds a .xz extension.
Example
xz examplefile xz -d examplefile.xz5. 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.bz26. 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.tar7. 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_i3deb8. 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.7z9. shar
shar creates simple shell archives useful for bundling scripts.
Installation apt-get install sharutils Example
shar examplefile > examplefile.shar unshar examplefile.shar10. 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.cpio11. ar
ar is the ancestor of the RAR format, still used on Debian‑based systems.
Example
ar cvsr examplefile.a examplefile ar -xv examplefile.a12. ISO (dd)
Use dd to create an ISO image from a DVD or other media.
dd if=/media/dvd of=/home/username/filename.iso13. 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.kgb14. 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 examplefile15. File Roller
File Roller is a GUI archive manager for Linux, supporting formats such as .iso, .7z, .gz, .zip, .bz2, etc.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
