📖 What is a TAR File?
A TAR file gathers many separate files and folders into a single file, so they can be moved, stored or shared as one neat parcel. The name is short for tape archive, a nod to the magnetic tapes that early computers used for backups, and although the tapes are long gone the format has stayed useful wherever a pile of files needs to travel together.
The surprising part, and the thing most worth remembering, is that a plain TAR file does not make anything smaller. It simply lines all your files up end to end inside one container, keeping every one of them at its original size. Picture packing a removal box. All your books go into a single box that is easy to carry, but the books themselves are exactly as big as before. That is a TAR file, one tidy parcel rather than a squeeze.
Because of this, a TAR file on its own is roughly as large as everything inside it added together. That sounds like a drawback, yet it is the point, since bundling and shrinking are treated as two separate jobs in the Unix world where TAR grew up. The bundling is TAR's job, and when you also want the parcel to take up less room, a separate compression step is added afterwards, which is exactly how the very common .tar.gz file comes to exist. So when someone hands you a TAR file, think of it first as a container, a way of keeping a group of files together, rather than as a way of saving space.
Key Characteristics
- Bundles many files into one parcel
- Does not compress, files keep their size
- Preserves permissions, dates and folders
- Grew up in the Unix world
Good to Know
- TAR means tape archive
- Also called a tarball
- Often paired with gzip as .tar.gz
- The Linux standard for bundling files
⚡ Quick Facts
| File Extension | .tar |
| Stands For | Tape Archive |
| What It Is | A bundle of files in one container |
| Compression | None on its own |
| Nickname | Tarball |
| Originated | Unix, released 1979 |
| Common Pairing | .tar.gz (with gzip) |
| Also Seen As | .tgz, .tar.bz2, .tar.xz |
📦 Bundling, Not Compressing
The single idea that makes sense of TAR is that bundling files and shrinking files are two different jobs, and TAR does only the first. Grasp that and everything else about the format falls into place.
When TAR gathers your files, it writes them one after another into a single stream, adding a small note before each one that records its name, its size, and details like permissions and the date it was last changed. Nothing is squeezed or rewritten, so each file arrives inside the archive byte for byte as it was, and the finished TAR weighs about the same as all the originals combined. This faithful copying is a strength rather than a weakness. It means a TAR file preserves the exact structure of a set of folders and the ownership and permissions of every file, which is precisely what you want when backing up a system or moving a project between machines. The trade-off is size, and that is where a compressor comes in as a second, separate step.
🔗 How .tar.gz Works
The double extension .tar.gz puzzles a lot of people, but it is really just a short history of what happened to the file, read from right to left.
The story reflects a habit of the Unix world, where each tool is built to do one job well and tools are chained together for bigger tasks. TAR does the bundling, and a compressor called gzip does the shrinking, so a compressed archive is made in two moves. First TAR packs everything into a single .tar parcel, then gzip squeezes that whole parcel down into a smaller file, and the result is named .tar.gz to show both steps. You will also meet the shorthand .tgz, which means exactly the same thing and dates from an era when file names were kept very short. The order matters to how it behaves. Because gzip compresses the entire bundle as one continuous piece, a .tar.gz tends to shrink better than a set of separately squeezed files, at the cost that reaching a single file inside means working through what comes before it. Other compressors can stand in for gzip too, giving you .tar.bz2 or .tar.xz, but the pattern is always the same, TAR to bundle, then a compressor to shrink.
Two jobs, two steps
# step 1 TAR bundles the files (no shrinking) docs/ + images/ + notes.txt -> archive.tar # step 2 gzip compresses the whole bundle archive.tar -> archive.tar.gz (smaller, aka .tgz)
🆚 TAR vs ZIP
People often assume a TAR file is the same as a ZIP file, and while both end up as a single file holding many others, the way they get there is different in a way worth understanding.
A ZIP file does two jobs at once, squeezing each file it contains and then collecting those squeezed files together, all in one action. TAR splits those jobs, bundling first and leaving any compression to a separate tool, which is why you meet it paired with gzip as .tar.gz. That difference has a practical side. Because ZIP keeps a small index of its contents, a program can jump straight to any one file and pull it out on its own. A compressed tarball is instead treated as one continuous stream, so pulling out a single file usually means working through the archive to reach it. In return, compressing the whole bundle as one piece often yields a smaller result, and TAR faithfully keeps the file permissions and ownership that matter on Unix systems. Neither is better in the abstract. ZIP is the natural choice on Windows and for easy cross-platform sharing, while TAR and .tar.gz are the customary choice across Linux for backups and for handing out software.
| Aspect | TAR (.tar / .tar.gz) | ZIP |
|---|---|---|
| Bundles files | Yes | Yes |
| Compresses by itself | No, needs gzip | Yes, built in |
| How files are compressed | Whole bundle as one | Each file separately |
| Grab one file quickly | Slower in a tarball | Fast, has an index |
| Keeps Unix permissions | Yes | Less reliably |
| Native home | Linux and Unix | Windows, everywhere |
🐧 Why TAR Is Still Used
Given that tapes are a museum piece, it is fair to ask why a format born to write them is everywhere in modern computing, and the answer comes down to a few things TAR does unusually well.
The first is faithfulness. TAR preserves the exact permissions, ownership, timestamps and folder layout of everything it holds, which is essential when you are backing up a Linux system or restoring one, since those details are part of how the system works. The second is its partnership with compressors, which lets you pick whatever shrinking tool suits the moment while the bundling stays the same, a flexibility that has kept TAR current as newer compressors have arrived. The third is simply that it is everywhere in the Unix world by long tradition, so source code, software packages and server files are routinely handed out as tarballs, and every Linux and macOS machine can handle them without any extra software. That combination of faithful copying, flexible compression and deep familiarity is why a format designed for magnetic tape remains the everyday way to bundle files across Linux.
📂 How to Open and Extract a TAR File
Opening a TAR file means unpacking the parcel to get the original files back, and how you do it depends on your system, though none of the routes are difficult.
On Linux and macOS the tar command handles everything from the terminal. A short instruction unpacks an archive, and the same command copes with a compressed tarball in one go by adding a flag that tells it to run the files through gzip on the way out. If you prefer clicking to typing, the file managers on most Linux desktops and the Archive Utility on a Mac will open a TAR or a .tar.gz when you double-click it and let you extract the contents. Windows has caught up here, since modern Windows 10 and 11 include the same tar command at the command line, and for a friendlier experience a free tool such as 7-Zip opens tarballs through a normal window, though it often works in two passes, first stripping away the gzip layer and then unpacking the bundle it reveals. Whatever method you choose, you finish with your files back exactly as they started, right down to their names, sizes and folder layout.
Extracting from the command line
# open a plain .tar archive tar -xvf archive.tar # open a compressed .tar.gz in one step (z handles gzip) tar -xzvf archive.tar.gz # just list what is inside without unpacking tar -tvf archive.tar
🛠️ How to Create a TAR File
Making a TAR file is the same job in reverse, gathering a set of files and folders into one archive, and it is just as quick once you know the shape of the command.
From a terminal the tar command builds an archive when you point it at the files or folders you want to include, and adding the same gzip flag used for extracting will compress the bundle into a .tar.gz in the one step. On a Linux desktop or a Mac you can usually select the files, right-click and choose the option to compress them, which produces a tarball without touching the command line. This is handy whenever you need to send a whole folder to someone, back up a project, or keep a set of related files together, since the recipient gets a single tidy parcel that unpacks to exactly what you put in. Building the archive and shrinking it are still two logical steps under the surface, but the tools let you do both with a single instruction when you want to.
Creating an archive
# bundle a folder into a plain .tar tar -cvf archive.tar myfolder/ # bundle and compress in one step -> .tar.gz tar -czvf archive.tar.gz myfolder/
🏷️ .tar.gz, .tgz and Other Forms
Once you know that a TAR file is a bundle and that compression is added separately, the family of related names stops looking confusing and starts making sense at a glance.
A plain .tar is the bundle on its own, uncompressed. Add gzip and you get .tar.gz, or its shorter twin .tgz, which is the form you meet most often. Swap gzip for a stronger compressor and the tail of the name changes to match, so .tar.bz2 uses bzip2 and .tar.xz uses xz, both trading a little speed for a smaller file. The useful trick is to read these names from the right, since the last part tells you which compressor was used and the .tar part tells you a bundle sits inside. A rarer sight is a .tar that has been compressed by a tool which keeps the .tar ending, but in everyday use the double extension is your clue, and any of these can be opened by the same tar command or archive tool once you know a tarball is waiting within.
🚩 The tar Command Flags
The tar command can look like a jumble of letters, but each one is short for a plain word, and once you know the handful that matter the commands read almost like sentences.
The letters split into two groups. First comes what you want to do, then come the details of how. To create an archive you use c, to extract one you use x, and to list what is inside without unpacking you use t. Alongside those, v asks for a verbose run that prints each file as it goes, and f says that the next word is the file name, which is why f usually sits last so the archive name follows straight after it. The second group picks a compressor, with z for gzip, j for bzip2 and capital J for xz, so the difference between making a plain bundle and a compressed one is often a single extra letter. Read a command like x, z, v, f and it simply says extract, through gzip, verbosely, from this file. The order is mostly flexible except that f should come last, and modern versions of GNU tar can even work out the compression on their own when you extract, so a bare x and f will open a gzipped or an xz archive without being told which.
| Flag | Short for | What it does |
|---|---|---|
-c | create | Make a new archive |
-x | extract | Unpack an archive |
-t | list | Show contents without unpacking |
-v | verbose | Print each file as it is handled |
-f | file | Name the archive (put this last) |
-z | gzip | Compress or read as .tar.gz |
-j | bzip2 | Compress or read as .tar.bz2 |
-J | xz | Compress or read as .tar.xz |
-C | directory | Extract into a chosen folder |
Everyday tar commands
# extract into a specific folder (it must already exist) tar -xzvf archive.tar.gz -C /target/folder/ # pull out just one file from the archive tar -xzvf archive.tar.gz notes/todo.txt # leave out files while building an archive tar -czvf backup.tar.gz --exclude="*.log" myfolder/
🗜️ gzip vs bzip2 vs xz
Because TAR leaves compression to a separate tool, you get to choose which one, and the three you will meet most often each strike a different balance between speed and file size.
Gzip is the everyday default. It is quick, gentle on the processor and understood by practically every system, so a .tar.gz is the safe choice when you simply want a smaller file without fuss. Bzip2 squeezes a little harder, producing a smaller .tar.bz2 at the cost of taking longer, which suits large text or log files where shaving off extra size is worth the wait. Xz goes furthest of all, giving the smallest file of the three, and a .tar.xz can run roughly a fifth to a third smaller than the same .tar.gz, but it is markedly slower to create. That trade is exactly why the Linux kernel is distributed as a .tar.xz, since it is compressed once by its makers and then downloaded by a great many people, so the extra time spent shrinking it pays off many times over in saved bandwidth. The rule of thumb is easy. Reach for gzip for speed and compatibility, bzip2 as a middle ground, and xz when the smallest possible size matters more than how long it takes.
| Tool | Flag | Makes | Speed | File size |
|---|---|---|---|---|
| gzip | -z | .tar.gz | Fast | Good |
| bzip2 | -j | .tar.bz2 | Slower | Smaller |
| xz | -J | .tar.xz | Slowest | Smallest |
❓ Frequently Asked Questions
A TAR file gathers many separate files and folders into a single file, so a whole group can be moved, stored or shared as one parcel. The name is short for tape archive, from the magnetic tapes early computers used for backups. The important thing to know is that a plain TAR file does not compress anything, it simply lines the files up inside one container at their original size, which is why it is often described as a bundle rather than a squeeze. It is a mainstay of the Unix and Linux world, where it is frequently paired with a separate compression tool to produce the familiar .tar.gz. So a TAR file is best thought of as a container that keeps a set of files together.
No, a plain TAR file does not compress anything, and this is the point that surprises most people. It bundles files and folders into one container but keeps each of them at its original size, so a TAR of a hundred files is roughly as large as those hundred files added together. Compression is treated as a separate job in the Unix tradition where TAR comes from, handled by a different tool applied afterwards. That is why you so often see the double extension .tar.gz, which means a TAR bundle that has then been compressed with gzip. If you want a smaller file, the compression comes from that second step, not from TAR itself, which only ever does the bundling.
A .tar file is the bundle on its own, holding your files together at full size with no compression. A .tar.gz file is that same bundle after it has been run through the gzip compressor, so it contains exactly the same files but takes up less space. You can read the extension from the right to see the history, the .gz says it was gzipped, and the .tar underneath says a bundle sits inside. In everyday use the .tar.gz form, sometimes shortened to .tgz, is far more common because it saves room, while a plain .tar turns up when compression is not needed or is being handled some other way. Both are opened with the same tar command or archive tool.
How you open a TAR file depends on your system, but every route is straightforward. On Linux and macOS the built-in tar command unpacks an archive from the terminal, and it handles a compressed .tar.gz in one go when you add the flag that tells it to run the bundle through gzip. If you prefer clicking, the file managers on Linux desktops and the Archive Utility on a Mac open a TAR or tarball when you double-click it. On Windows, modern versions include the same tar command at the command line, and a free tool like 7-Zip opens tarballs in a normal window, though it may need two goes, one to peel off the gzip layer and one to unpack the bundle underneath. Whichever way, your original files come back intact.
Both TAR and ZIP end up as a single file containing many others, but they work differently. ZIP does two jobs at once, compressing each file and collecting them together in one action. TAR splits those jobs, bundling the files first and leaving any compression to a separate tool, which is why it pairs with gzip as .tar.gz. A practical result is that ZIP keeps an index so a program can pull out one file directly, whereas a compressed tarball is one continuous stream, so reaching a single file usually means reading through what comes before it. In exchange, compressing the whole bundle together often gives a smaller file, and TAR keeps the Unix permissions and ownership that matter on Linux. ZIP suits Windows and cross-platform sharing, while TAR suits Linux backups and software.
A tarball is simply an informal nickname for a TAR archive, the single file that a TAR bundle produces. In practice people most often use the word for a compressed one, a .tar.gz or .tgz, since that is the form usually handed around, but strictly it covers a plain .tar too. The term is very common in the Linux and open-source world, where software and source code are routinely distributed as tarballs for people to download and unpack. So if someone tells you to grab a tarball or to untar something, they are talking about a TAR archive, and you open it with the same tar command or archive tool you would use for any .tar or .tar.gz file.
TAR is favoured on Linux mainly because it faithfully preserves the file permissions, ownership, timestamps and folder structure that Linux systems rely on, which makes it ideal for backups and for restoring files exactly as they were. It also pairs cleanly with whichever compressor you prefer, so you can choose gzip for speed or a stronger tool like xz for a smaller file while the bundling stays identical. On top of that, TAR is woven into Unix tradition, so source code and software packages are distributed as tarballs by long habit and every Linux machine handles them out of the box. ZIP is perfectly usable on Linux too, but for system backups and software distribution the faithfulness and flexibility of TAR make it the natural pick.
Each letter is shorthand for one instruction, and together they read almost like a sentence. The x means extract, so you are unpacking rather than creating. The z means work through gzip, needed for a .tar.gz. The v means verbose, which prints each file as it is handled so you can see progress. And the f means the next word is the file name, which is why it sits last, with the archive name following right after. So tar -xzvf archive.tar.gz says extract, through gzip, verbosely, from this file. To create instead of extract you swap the x for a c, and for other compressors you swap the z for a j for bzip2 or a capital J for xz. Modern versions can even detect the compression themselves, so a plain tar -xf often works too.
By default a TAR file unpacks into wherever you currently are, but you can send the contents somewhere specific with the capital C option followed by the target folder. For example, adding -C then a folder path to an extract command drops the files there instead of in the current location. The one catch is that the destination folder has to exist already, since tar will not create it for you, so make the folder first if it is not there. This is handy when you want to keep an extraction tidy, unpack a backup into its own place, or install files into a particular directory. A graphical archive tool offers the same choice through an extract-to dialog where you simply pick the destination.
Yes, you can pull out a single file rather than unpacking everything, by naming that file at the end of the extract command exactly as it appears inside the archive. If you are not sure of the exact name, list the contents first with the t option, which shows every path without unpacking anything, then copy the one you want into your extract command. This saves time and space when you only need one item from a large archive. Bear in mind that with a compressed tarball the tool still has to read through the archive to reach your file, since a .tar.gz is a continuous stream rather than an indexed collection, but you still end up with only the single file you asked for rather than the whole bundle.
They differ in the balance between speed and file size, so the best one depends on your priority. A .tar.gz uses gzip, which is fast and understood everywhere, making it the sensible default for general use. A .tar.bz2 uses bzip2, which packs a little tighter than gzip but takes longer, a fair trade for large text or log files. A .tar.xz uses xz, which gives the smallest file of the three, often a fifth to a third smaller than the same .tar.gz, at the cost of being much slower to create. That is why big downloads compressed once and fetched by many, such as the Linux kernel, favour xz. For everyday use gzip is usually right, and you only reach for the slower options when the smaller size genuinely earns the extra time.
Use the list option, the letter t, in place of the extract letter. Running tar with t and f, plus the compression letter for a compressed tarball, prints every file and folder inside the archive along with details like sizes and dates, all without unpacking a thing. This is useful for checking what an archive contains before you commit to extracting it, for confirming a backup holds what you expect, or for finding the exact name of a file you want to pull out on its own. A graphical archive tool does the same when you simply open the tarball, showing its contents in a window so you can browse before deciding what to extract.
A TAR file is a container of other files, not a program, so the archive itself does nothing when opened, and unpacking one is safe in the ordinary sense. The care needed is about what is inside, exactly as with a ZIP, since a tarball could hold anything from harmless documents to a risky script or program placed there by someone. The sensible habits are the usual ones, only open tarballs from sources you trust, glance at the contents with the list option before extracting so nothing is a surprise, and be wary of an archive that scatters files across your system instead of tidily into one folder. Treated with that everyday caution, TAR files are no more dangerous than any other way of receiving a bundle of files.
📝 Summary
A TAR file is a tape archive, a single file that bundles many files and folders together so they can travel as one parcel, marked by the .tar extension and nicknamed a tarball. Its defining trait is that it does not compress, it lines the files up end to end at their original size while faithfully recording each one's name, permissions, ownership and dates, so a plain TAR weighs about as much as everything inside it combined. That is by design, because the Unix world where TAR was born in 1979 treats bundling and shrinking as two separate jobs, so compression is added as a second step by a different tool. Pairing TAR with the gzip compressor produces the very common .tar.gz, also written .tgz, and swapping the compressor gives .tar.bz2 or .tar.xz, with the tail of the name always naming the tool used and the .tar showing a bundle sits within. Compared with ZIP, which compresses each file and collects them in one action, TAR splits those jobs, so a compressed tarball is one continuous stream that squeezes well but makes reaching a single file slower, while ZIP keeps an index for quick access and is the natural pick on Windows. TAR endures because it preserves the exact permissions and structure Linux systems depend on, pairs flexibly with any compressor, and is the long-standing way software and source code are shared across Linux. You open one with the built-in tar command on Linux, macOS and modern Windows, or with a tool like 7-Zip, and creating one is the same command in reverse, gathering files into a bundle and optionally compressing it in the same step.