Receiving a .tar.gz or .tgz file for the first time can be puzzling. Once you know what the format is and why it exists, opening and making these files becomes simple.
TAR is only a bundle
TAR joins many files and folders into one long file. The name comes from tape archive, from the days when data was written in sequence onto magnetic tape, and today it still plays the bundling role.
TAR itself does not reduce size. Its big advantage is that it records each file's name, folder location, modification time and permissions alongside the content. The name tar stands for tape archive, a method from the days of writing files in sequence onto magnetic tape that has survived to the present.
Joins many files into one
Keeps names, folders, permissions and timestamps
Size is about the sum of the originals
When GZ is added
GZ is a format that shrinks a single file. Applying it to the one-file TAR bundle shrinks the whole thing at once and produces a .tar.gz. The shorter .tgz means the same.
Unlike ZIP, which compresses file by file, the whole bundle is shrunk together, so compression tends to be good when many files are similar. The trade-off is that pulling out one file may mean reading from the start, which can be slower. Know that there are other compression variants too. Names such as .tar.bz2 or .tar.xz use a different shrinking method with the same principle; the last part of the extension tells you how it was shrunk.
.tar — bundling only
.gz — shrinking one file
.tar.gz or .tgz — bundled, then shrunk as a whole
Why servers and developers use it
On servers, file permissions and folder structure matter, and TAR preserves them well. That is why it has long been a standard for software releases, server backups and configuration bundles.
For Windows users it can feel unfamiliar, so when sending to ordinary users ZIP is the friendlier choice. Even if you rarely deal with it day to day, you will meet this format whenever you receive development material or server backups. Knowing how to open it prevents panic.
Software release files
Server backups and migrations
Bundles of development material
Opening and making them
To open one, drop it on the Extract TAR.GZ tool, look at the list and pull out the files you need. If you have a single file ending only in .gz, the Gzip tool can handle that.
When making one, remember the order: bundle first, shrink last. If you only have one file rather than a folder, GZ alone is enough. When a single file is shrunk with GZ, .gz is added after the original name, and extracting restores the original name. If the names do not line up, it may be another format.
Received a .tar.gz — check the list with Extract TAR.GZ
Only a single .gz — expand it with Gzip
Look at the paths inside before extracting
What to watch when extracting
Before extracting an archive from an untrusted source, look at its list. If paths contain markers that climb out to parent folders, or the file count seems oddly large, it is safer not to open it.
Extracting into a new, empty folder prevents the accident of overwriting existing files. If you need to keep execute permissions, bundling with TAR has an advantage; for ordinary documents, ZIP is more convenient.
Check the list first when the source is unknown
Extract into a new empty folder
Keep the original archive until you have verified the result