Fundamentals 9 min read

Why Does a .tar.gz File Have Two Extensions?

The article explains that the .tar.gz suffix reflects a two‑step pipeline where tar archives files into a byte stream and gzip compresses that stream, a design rooted in Unix's 1970s philosophy of single‑purpose tools cooperating via text streams.

ITPUB
ITPUB
ITPUB
Why Does a .tar.gz File Have Two Extensions?

While recompiling nginx, the author noticed the .tar.gz filename and wondered why it contains two suffixes.

tar first appeared in January 1979 in Unix Version 7 as Tape ARchive, a tool that simply concatenates files into a byte stream for tape backup; it does not perform any compression.

In October 1992, Jean‑loup Gailly and Mark Adler released gzip (version 0.1), a free replacement for the patented compress utility, using the DEFLATE algorithm to compress a byte stream.

Because both utilities operate on streams, the common practice is to pipe tar’s output to gzip: tar cf - mydir | gzip > mydir.tar.gz The resulting file carries both extensions, each indicating one stage of the pipeline.

GNU tar later added the -z option so that tar can invoke gzip automatically, but the actual compression is still performed by gzip, not by tar itself.

This design follows the Unix philosophy articulated by Doug McIlroy in 1978: programs should do one thing and do it well, cooperate via text streams, and treat streams as the universal interface. The .tar.gz suffix is a literal embodiment of that philosophy.

By contrast, Windows tools such as zip combine archiving and compression in a single executable, reflecting a different design choice.

“Write programs to do one thing and do it well. Write programs to cooperate. Prefer text streams as the universal interface.” – Doug McIlroy

Thus, .tar.gz is not a single format but the product of a pipeline of two single‑purpose tools, a design that has persisted for over four decades.

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.

Command LineUnixgzipcompressionfile formatstar
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.