Why Does a .tar.gz File Have Two Extensions?
The article explains that a .tar.gz file isn’t a single format but the result of two separate Unix tools—tar for archiving and gzip for compression—combined via a pipeline, tracing their historical origins, design philosophy, and why the dual extension persists today.
When the author downloaded nginx-1.27.4.tar.gz and ran tar -xzvf, the double suffix sparked curiosity about its meaning.
Tar originated in 1979 as part of Unix Version 7, standing for Tape ARchive . It simply concatenates files into a byte stream suitable for tape storage, using 512‑byte blocks matching the V7 filesystem sector size. Tar does not compress; a 100 MB directory remains 100 MB after tar.
In 1992, Jean‑loup Gailly and Mark Adler released gzip, a tool that compresses a byte stream using the DEFLATE algorithm, created as a free alternative to the patented compress utility. Gzip also works on a single stream and does not understand directories.
Because tar only archives and gzip only compresses, the two are chained with a Unix pipe: tar cf - mydir | gzip > mydir.tar.gz The left side ( tar cf - mydir) writes the archive to standard output (the dash -), the pipe | passes that stream to gzip, and gzip writes the compressed result to mydir.tar.gz. The resulting filename therefore reflects both stages: .tar for archiving and .gz for compression.
GNU tar later added the -z option so users could invoke gzip automatically, yielding commands like tar -xzvf archive.tar.gz. The z flag tells tar to invoke gzip internally; tar itself never gained native compression capabilities.
This design follows the Unix philosophy articulated by Doug McIlroy in 1978: each program should do one thing well, programs should cooperate, and the preferred interface is a text stream. The pipe symbol |, invented by McIlroy, embodies this philosophy.
In contrast, the Windows/DOS world introduced formats like .zip (Phil Katz, 1989) and later .rar (Eugene Roshal, 1993) that combine archiving and compression in a single executable, reflecting a different design choice.
Later Unix compression tools such as bzip2, xz, and 7z follow the same two‑step pattern, producing extensions like .tar.bz2 and .tar.xz. The article emphasizes that while compression algorithms evolve, the Unix principle of separating archiving and compression remains unchanged.
Thus, a .tar.gz file is not a single format but the product of a pipeline that first archives with tar and then compresses with gzip, a practice that has endured for over four decades because the underlying philosophy is still considered sound.
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.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
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.
