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 taryum install tarExample
fallocate -l 512M um.imgtar -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 gzipyum install gzipExample
gzip examplefilegzip -l examplefile.gzgzip -d examplefile.gzgzip -r examplefile3. lzma
lzma offers faster compression than bzip2 and is built into most Linux distributions.
Example
lzma -c --stdout examplefile > examplefile.lzmalzma -d --stdout examplefile.lzma > examplefile4. xz
xz is the successor of lzma; it compresses single files and automatically adds a .xz extension.
Example
xz examplefilexz -d examplefile.xz5. bzip2
bzip2 provides tighter compression than gzip but requires more RAM; use -s for low‑memory mode.
Example
bzip2 examplefilebzip2 -s examplefilebzip2 -v examplefilebzip2 -d examplefile.bz2bunzip2 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 examplefilepax -f examplefile.tarpax -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_i3debdpkg -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 examplefile7z e examplefile.7z9. shar
shar creates simple shell archives useful for bundling scripts.
Installation apt-get install sharutils Example
shar examplefile > examplefile.sharunshar examplefile.shar10. cpio
cpio reads a list of filenames from stdin and creates an archive; it requires no installation.
Example
cd /tmpls | cpio -ov > /home/username/backup.cpiocpio -idv < backup.cpio11. ar
ar is the ancestor of the RAR format, still used on Debian‑based systems.
Example
ar cvsr examplefile.a examplefilear -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 examplefilekgb 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.
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.
