GNU tar: an archiver that only packs, leaving the squeezing to gzip and xz
Version 1.35
Summary
GNU tar turns a tree of files into one container and hands the shrinking to gzip, xz or zstd, so creating, extracting, listing and pulling out a single file each take one short command.
Recommend- Name
- GNU tar
- Version
- 1.35
- Pricing
- Free
- Open source
- Open source
- Operating system
- LinuxmacOS
- Updated
- 2026-10-05 17:23
GNU tar is the archiving tool that practically every Unix-like system ships with, and it is what most people reach for when a pile of files has to become a single file. What surprises newcomers is that tar compresses nothing at all. It only concatenates files and directories into one .tar stream; the shrinking happens afterwards, done by a compression algorithm such as gzip, xz or zstd. That division of labour is why the familiar extensions come in pairs: .tar.gz, .tar.xz, .tar.zst. The first half names the container, the second half names whatever squeezed it.
Two jobs, kept apart
The single most useful idea for understanding tar is to stop treating archiving and compression as one operation. Archiving means taking many files and writing them one after another into a continuous stream, with the directory layout and the permission bits preserved along the way. Compression means taking that stream and making it smaller. tar does the first and hands the second to whichever tool is asked for, joined through a pipe. A short flag decides which one: -z calls gzip, -j calls bzip2, -J calls xz. Because the two halves are separate, the archiving layer never has to care which algorithm is in fashion this year, and a format designed decades ago keeps working with codecs that did not exist when it was written.
The commands that actually get used
Almost all daily work comes down to a handful of invocations. To build an archive without touching its size, tar -cf backup.tar folder/. To build one and compress it in the same pass, tar -czf backup.tgz folder/. To unpack, tar -xf backup.tgz, and tar works out the compression type by itself, so there is no flag to memorize. To look inside without extracting anything, tar -tf backup.tgz. Add -v when it helps to watch the file names scroll past, use --exclude to leave something out, and use a single dash to read from standard input when the stream arrives over a pipe. Recovering one file out of a large archive does not require unpacking the whole thing: append the path to the extraction command, tar -xf backup.tgz path/file, and only that file comes out. All of this runs unchanged in a Linux terminal and in the one on macOS, which is why it counts as basic literacy for anyone who administers a machine.
Beyond the basics
Incremental archiving is the feature that gets overlooked. With a snapshot file passed to -g, tar records what it has already stored and packs only what has changed since that snapshot was written, which is exactly the shape a periodic differential backup wants. tar also handles very long file names and symbolic links without mangling them, and it follows the POSIX standard closely enough that a tree unpacked on a different system keeps the same structure. Paired with ssh, an archive can be streamed straight to a remote machine, skipping the intermediate file on local disk entirely.
Why it stayed
Software releases, source code distribution and system backups all end up passing through tar at some point. Its format is open, it runs everywhere, it arrives preinstalled on essentially every Linux distribution, and it has kept compatibility stable for a very long time. Newer archive formats have appeared and some of them suit particular jobs better, yet tar holds its ground through sheer ecosystem inertia: the tooling built around it, the habits of the people who use it, and the sheer number of scripts that quietly assume it will be there.
Small tricks worth knowing
Reading one file out of an archive without ever writing it to disk is easy with a decompressor chained in front. Something like zcat backup.tgz | tar -xOf - path/file prints the contents of a single file to standard output, which is handy when the only thing wanted is a quick look at a configuration file buried inside a release tarball. Combine the snapshot flag with the system scheduler and a backup chain builds itself: a full archive at long intervals, incremental ones in between, which costs less space and still allows a rollback to any point the chain covers.
Licence and standing
GNU tar is released under GPLv3 as free software, which means anyone may use it, modify it and pass it on. That licence is a large part of why the format never became anyone private property, and why an archive written decades ago still opens today on a machine built last week. For a tool that does one narrow thing, that longevity is the strongest recommendation it could have.