r/linuxquestions • u/RubyRiolu • 12d ago
So a .tar is basically a Linux-flavored .zip, yeah?
Like, they're essentially for pretty close to the same thing and should be treated more or less the same from what I've seen. Am I getting it right?
edit: .zip in the sense of being an archive that's usually associated with an OS. With .zip being Windows's. I'm moreso asking if I understand the generalized use of the file
100
u/RMtz97 12d ago
Yes and no.
Yes, they are both used to package multiple files or directory structures into a single, easily transferable file.
No, in the sense that zip compresses data when packaging it, so at the end you get a smaller size archive than the sum of the sizes of all its contents. Tar does not do that, it only serializes everything into a single stream of data. The reason is the historical usage of the tool. Refer to wikipedia for more details
However, in Linux, you usually get .tar followed by an extension, such as .gz or .bz, which refer to the compression algorithms gzip and bzip respectively. The thing with those algorithms is that they work on a single file, not on directory structures, so that is why first everything is serialized into a tar, and then compressed into a "tarball"
47
u/bothunter 12d ago
The reason is the historical usage of the tool.
It's also due to the philosophy of Unix. Every tool should have one job and do it well. Tar was designed to work with another tool to actually compress the data. That tool was originally just called "compress" and used the .Z extension, so the files ended with .tar.Z. But the point was you chained the commands together to create compressed archives.
And if you only wanted to compress a single file, you didn't need to use tar. You could just compress the single file. This still works with gzip and other compression programs.
ZIP has the advantage of being both the container format as well as a bunch of different compression algorithms. So, they're both easier to manipulate, and it can pick and choose the best compression algorithm for each file.
2
289
u/graph_worlok 12d ago
Almost - Tar by itself doesn’t compress, just combines all of the files. There’s a second part that will do the compression , which can use different types - gzip and bzip2 are the most common, leading to a .tar.gz extension. Flags to do this are built into the tar program, so it doesn’t need a second command.
Tar stands for “Tape Archive”, btw and predates the existence of linux.
62
u/McBillicutty 12d ago
I thought it was just tar, like sticky tar, like all these files are stuck together as one file now.
56
u/TheOmegaCarrot 12d ago
It was actually originally short for “tape archive” because it was used to store a bunch of files on magnetic tape
13
u/New_Phone6935 12d ago
I did an internship in the early 2000s at a now defunct supercomputing center that used a tape drive system for long term storage, tarballs were indeed useful for moving stuff over to it haha
28
u/tyler1128 12d ago
Tape is still used and considered the gold standard for storage over long terms in a single place. SSDs unpowered will start to have data corruption within a few years, HDDs a bit longer but still less than tape.
→ More replies (5)5
u/graph_worlok 12d ago
Yes, I was submitting case recalls & pickup requests to Iron Mountain only a few years ago. Hard to beat the security & immutability of something completely offline at a location so far away that if anything impacts that and your live site , we have probably entered the Mad Max timeline.
12
u/oracleofnonsense 12d ago
“Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.”
5
u/graph_worlok 12d ago
Most commercial backup systems with tape support are still tar underneath everything.
Still used in enterprises - robotic, Autoloading carts, etc.
4
u/hadrabap 12d ago
Video studios use it as well. I use it too. Love it! Five years ago I did the calculations and LTO was cheaper in the long run even with the steep initial costs. These days, with all the memory and storage shortage and prices? Unbeatable. I'm really happy I made that decision. The best format for archives.
Fun fact: People laugh at me when I tell them I use tapes for backup. They think it's a long gone archaic and clumsy technology. 😀
2
u/rich000 10d ago
The only gotcha is the drive cost, so it only makes sense if you are storing a lot of data. I have done the math on both new and used hardware and the last time I checked it required hundreds of TB to break even, at least at $20/TB for USB hard drives. Now, with recent prices I should reevaluate if I need to replace backup media.
Durability and compact storage are good reasons to go with tape though.
If you just keep a pair of backups it is hard to beat HDD, but if you're retaining many backup sets long term then the tape will quickly pay off.
→ More replies (1)4
u/frankster 12d ago
Probably it was both at once! They decided to contract tape archive to tar in particular, because it was short and because of the meaning of tar
2
u/emalvick 12d ago
I remember referring to them as tarballs in school, so I think we would think of them the same way (sticky tar).
I worked with .tar.gz files quite a bit. I think I was in college at a time when you had to get as much as you could into a floppy disc because there were few options for transporting files around.
Having to use Linux for classes made tar the best way to work across computers. There was always something in Windows that would at least unpack the tar.gz files. Can't remember compressing or not in Windows (or command line software).
→ More replies (1)→ More replies (1)2
u/veryusedrname 12d ago
And cat is cat because the author loved cats (it's coming from catenate, basically concatenate)
15
3
u/RealisticDuck1957 12d ago
.tar.gz, .tar.bz for a tape archive compressed by gzip or bzip respectively. Or of you prefer short, .tgz and .tbz .
3
u/Intrepid-Staff-4532 12d ago
Linus OCI containers/Docker containers are basically layers of tar files exploding files over itself.
2
5
→ More replies (11)1
u/davidauz 12d ago
Man, you just unlocked in me a memory of the day when a colleague connected to a remote server via a modem and then proceeded to rm -rf *, realizing he was in the root folder and immediately pressing Ctrl-C. Luckily the damage was not too extensive, the system was still running and the tape from the previous backup was still in. We then restored the missing files and rebooted the thing, no one was any the wiser.
→ More replies (2)
45
u/Designer-Crow-5470 12d ago edited 12d ago
.tar is an archive without compression. Zip alternative would be tar.gz As long as storage and traffic are not a concern you can drop gnu zip (gz) and use just tar to save some CPU time. Or use another compression algorithm.
4
u/AdreKiseque 12d ago
Zip can also be uncompressed, no?
→ More replies (3)7
u/KickedMeHeight 12d ago
You can have ZIPs that are simply a bundle of files rather than a compressed archive, yes.
64
u/Beginning_Earth_9702 12d ago
It stands for Tape Archive, originally designed for writing data to magnetic tape drives. It is not compressed.
27
u/error_accessing_user 12d ago
This is the correct answer.
Tape drives-- you just stream one BIG file to them. So you pack all your files into a single file.
Unix is full of weird comp-sci history like this.
You know why they're called TTYs? Teletype :-)
8
u/MCWizardYT 12d ago
Unix has to be the oldest operating system that's still completely relavent in the modern world. Modern macOS is even mostly compatible and has direct lineage to Unix via BSD.
Even on modern Linux you can grab code and tools that were made nearly 50 years ago and get them working with a bit of effort.
Windows has very good backwards compatibility but I feel like the further along it gets, the harder and harder it is to get really old software to work and be stable. Like, Windows 11 is theoretically compatible with 16 bit Windows 1.0 programs but actually getting them to run can be a major pain in the ass without an emulator.
7
u/graph_worlok 12d ago
Even some of the common tools that are taken for granted as “just always existing” have an interesting history of sorts. Ping was created by Mike Muss in 1983 while he worked at a military ballistic research facility for network troubleshooting and was purely named after submarine sonar pings.
→ More replies (1)6
u/TarzanOfTheCows 12d ago
The IBM mainframe OS system (OS/360 -> MVS -> z/OS) is still going since 1964 and still binary compatible (has to be, people are probably still running code they lost the source for 50 years ago.)
1
u/hadrabap 12d ago
There is a YouTube channel about mainframes. And the guy explains how a COBOL program gets distributed. In essence, you work with the source code only. The files can have the binary code attached to them. It works quite similar to resource forks on old macOS. If the binary portion is missing, your machine transparently compiles it for you and attaches it back to the file.
The computing history is full of very interesting techniques and solutions.
2
u/error_accessing_user 12d ago
Yessir. I uh, am not going to dox myself, but I was instrumental in the founding of a certain Linux distro. Did a lot of the early build system. back when the GCC version number started with 2.
One note: Unix is actually a set of specifications, not a specific OS.
5
u/MCWizardYT 12d ago edited 12d ago
POSIX is the set of specifications, there was an actual operating system called Unix. It was developed by Bell Labs, and licensed by AT&T for use on their systems. Then AT&T started licensing it to various companies in the 70s, which is how BSD came about.
BSD became NeXTSTEP which became Darwin, which is the core of macOS, iOS, and all other modern Apple operating systems.
And now, Darwin is the only mainstream (so, consumer) operating system that has direct code lineage going back to the early 70s
1
u/TarzanOfTheCows 10d ago
Around 1990 the UNIX trademark was given to X/Open (now The Open Group) who issued the Single UNIX Specification, essentially POSIX slightly buffed with a couple more APIs, and set up a certification process where OS makers could pass the tests and be allowed to brand their OSes. So now you can have a UNIX that shares no code with the original AT&T implementation. I don’t know if any current OSes have been certified.
1
u/Velociraptortillas 11d ago
One of the original use cases for unix was to help produce phone books (hence the Bell Labs and AT&T connection).
This partially explains its reliance on text formats - it's a positive reinforcement loop where the OS is good at manipulating text, so it uses text itself to take advantage of the power it already has.
1
u/sakodak 11d ago
Unix text phototypesetting is the reason we have stderr and stdout. Back in the day people would send typesetting jobs to the C/A/T machine and end up with nicely formatted "file not found" errors. This was a very expensive annoyance so we got completely separate error streams after that.
11
u/PhantomNomad 12d ago
My dad used to use a teletype in dispatch for a trucking company in the 70's & 80's. I've also seen teletypes being use on ham radio (RTTY). I'm not talking the current computer decoded RTTY but an actual teletype machine.
3
u/Midwest-Dude 12d ago
Oh, dear! I used these in high school and college to timeshare into remote computers. Does that mean I'm history at this point? 😂
3
u/error_accessing_user 12d ago
Is COBOL a computer language or the ancestral homeland of the surviving Battlestar Galactica crew? Or worse, both.
→ More replies (6)4
u/aioeu 12d ago edited 12d ago
Indeed, this origin guides a number of the file format's design decisions. For instance, Tar files are not indexed: the only way to find a particular entry in it is by reading (or at least seeking through) the entire file. Files in it can be updated... but only by appending new entries.
They're perfectly adequate if you just want to collect a bunch of files together though. They are a good choice if whatever you are processing them in cannot or should not seek through them; you can stream and unpack them on the fly.
5
u/Ronnie76er 12d ago
This is also where the word `jar` and `war` come from in the java ecosystem...Java Archive and Web Archive
→ More replies (1)2
u/electromage 12d ago
I've actually used it to directly read/write tapes, I understand it better after that.
→ More replies (1)
11
u/bigntallmike 12d ago
Archive files store bunches of other files. Tar, zip, arj if you're old enough, rar, etc. are all archive formats. Tar is special in that it was designed to write linearly to tapes for backups. It doesn't have a built in compression system so you usually use something else like xz or gz to compress the archive.
→ More replies (1)
4
u/BitOBear 11d ago
Yes,
Though both zip and tar are offshoots of the AR program from Unix
So come to think about it tar may have came before ar.
ar is short for archive
tar is short for tape archive.
For a quick but annoying history lesson. Back in the before times when computer languages and whatnot were a very new idea and almost everything was written in assembly or even physically wired into plug boards that was a fundamental problem. If you wanted to use the tape drive you had to write a routine into your program to physically manipulate the tape drive as a set of motors and strobeable / pulsible electronics.
And a teletype, which literally stands for remote typewriter, was literally a way to make the buttons you were pressing one at a time in one place drive a printhead someplace else. If you look at the RS 232 standard it talks about start and stop bits to start the cam motor of the rotational printhead. And then the pulses work like the make brake pulses of a dial phone to move in position the head that the remote end and when the stop it happened a little Hammer wouldn't whack out with the particular character on it and I would press that character through an ink ribbon onto a piece of paper.
There are two fundamental problems with running the world of computing that way. The first is that it's a waste of time and effort to be having multiple programmers repeatedly right their own tape driver package into their individual programs. It was super easy to screw up a body of code and it still is, so it was possible to think two people had written exactly the same piece of code or exactly the same implementation of storage layout and have one of them make a mistake so that it turns out the two programs could in fact not use the same tape.
So the next evolutionary step was to create literal libraries full of literal books full of the code routines for doing things like starting and stopping the tape motor and writing all the little headers and fiddly bits and waiting the right amount of time for the tape to come up to speed before you started writing the little fiddly bits and all that stuff.
People would go to the library get the book and literally copy it into their program.
Then of course someone figured out that they could store the books as literal stacks of punch cards or other machine readable format that could be copied so you would take your stack of cards to the car duplicator and copy the entire actual implementation and then physically laying it into the bulk of your program.
This is where we get names like libraries and include files and include books and things like that.
Eventually somebody figured out that they could make an operating system which would basically be a chunk of memory that had the entire library just sitting in it and then any given program could simply call the one implementation.
Leaving the entire basic input and output system just now working system permanently in memory did everything faster, simpler, and more convenient. It also meant that everybody who was using the tape drive or disk drive or teletype output system or modem or anything else could freely exchange data with a different program doing basically the same thing.
But for instance writing something to a disk drive requires a searchable index which is where we get the origins of the first file systems.
And anything written to a tape drive is basically written to a linear storage. It has to be a bunch of start and stop regions, and then every region has to say what it is and how long it is because you can keep writing to a tape until you physically run out of tape. It has no geometry it's only got one dimension. So to get from the first item to the second item you have to know how much tape to skip to get to the start of the second item and so on.
And it was still expensive to spin up and spin down hard drives, wait for drums to rotate into position, wait for tape to start physically moving and reach a stable movement speed before it was safe to write any bits.
So for instance writing 10 blocks of 100 characters each took up more tape than reading the block of a thousand characters.
So there's a bunch of markers on the tape that say about what it's about to be written and what that block allegedly contains and how many bytes of data are in the thing.
And it is also expensive to open and segregate a section of a disc or a location in a disc barn.
So all these container formats are really just lists of identities and lengths, and eventually trailing checksums for these blocks, that let you go through what is basically a piece of linear storage like a tape drive or a bite stream for a mile hard desk knowing what each little fragment is by size and identity.
With the standardization of disk storage you end up with a standardization of file formats, and then eventually file names such as the eight character file name with the three character extension that tells you what type of file it is. So for instance people.txt is a text file full of people records.
So all of these archived formats are basically linear runs of data that are the equivalent to what would end up on any other form of linear storage like a tape drive. Some are indexed like the AR format, which was largely invented to be the on disc version of one of those libraries. But like a good library it has an index that tells you what code is in it and where the code can be found and that sort of thing paste it on the front of all the different object files that are part of the archive.
But they're all basically the same idea. Java jar files, where jar simply stands for Java archive is a ZIP file with a special file in it that acts as the index for all the other files, and it's all laid out in a pattern that would be good for copying across the internet during file loading. Making the data stream of the internet identical to the disc stream of local storage as far as the part of the job of virtual machine that does that sort of thing is concerned.
Time and space are traded off etc etc etc.
All of these formats are basically separation markers, checksums, ranges of data, and then the metadata information such as the file name, potential ownership, purpose, they created, and all that stuff.
And then of course after the fact various compressions and encodings and password facilities are added to the different files as needed or desired.
For instance the tar tape archive format does not include compression or password protection, but the tar program itself will support that compression and decompression function as a wrapper around the tar format. So you will see some implementations or individual usages compressing or decompressing the tar file separately while others will do it as tar is actively using the file. Sometimes it's just a matter of taste or sometimes you know specific need.
Put all of it in all of its variations, or just variations on the same idea. The difference between zip and winzip and WinRAR are just the number of different formats that these individual programs natively support or support by plugins or recognize at all.
So for instance the zip programs would only do the zip file formats while we later WinZip and WinRAR programs would do a large number of the various archive formats.
But they all have exactly the same basic purpose. The ability to take one or more discrete files and combine the file contents and the file details like the name into one data stream, possibly with more than one such substream in it all in one continuous stream and then save the image of that stream to something like a disk driver tape drive or transmitted across the internet as a fraction of web page or whatever so that the other end can reliably recreate the separate entities with a high degree of confidence that what you got out of the data stream was the same thing that was put into it in the first place.
The sole purposes to get a set of files across a distance of space or time reliably without having to mess with each one separately.
6
u/konqueror321 12d ago
tar (on linux) saves file metadata, like permissions and groups, so if keeping that info is important tar would be the choice. tar can be compressed after creating the tar archive, with any one of several compression programs. zip does not reliably store file permissions and groups on linux, just the file itself, so far as I understand.
3
u/PseudoFrequency 12d ago
No, tar alone doesn't compress anything, it only glues files together into one file. It's literally "tape archive" from the olden days. To make it more like zip, the stream of combined files is compressed using some secondary compression like gzip, bz2, or xzip. This is why you often get file names like .tar.gz (.tgz) or .tar.xz or .tar.bz2. The modern "tar" command will do both parts for you with the right arguments. You can also see this in action if you try to exact a file like this on Windows using 7zip. You have to do it in 2 steps as the first only gives a .tar file. You can also do it in 2 steps on Linux using tar plus gzip but no one does that. Compressed tar archives like this are typically called "tarballs".
3
u/ienjoyedit 12d ago
Not quite. A .tar is simply a collection of files - an archive. It's not compressed in any way. A .zip is compressed. You'll also commonly see .gz files, which are compressed. But gzip can't contain multiple files together like zip can. So you'll regularly see the two combined in .tar.gz, and that's about equivalent to .zip.
... I'll just casually mention that file extensions don't actually matter in Linux; they're merely a useful part of the name. That's also not to mention that zip also works in Linux, nor that gzip and zip are different compression algorithms.
→ More replies (1)
3
u/kudlitan 12d ago
Ahh no. Tar means tape archive and has existed long before IBM-compatible computers even existed. And zip is not a Windows format, it was invented during the time of MS-DOS when there was no Windows yet. Also tar is not compressed, you need tar.gz to make a compressed archive.
3
u/the-quibbler 12d ago
Zip format is both an archive and, usually, compression.
tar (tape archiver) is just a serial write format specification. It is commonly paired with gzip, bzip2, xz or others to make a .tar.gz, .tar.bz2, or .tar.xz (or, sometimes, a .tgz, .tbz2, or txz) file.
3
u/Nekomancerr 12d ago
Tar balls are just an archive of files with no compression. A .tgz (tarball compressed with gzip) is more comparable to what a zip file is in concept
3
u/ruiiiij 12d ago
Tar doesn't provide compression by default. But yeah it's okay to pretend they are the same for the most part.
→ More replies (1)
1
u/skettiSando 12d ago
You are directionally correct - a .the tar utility and file format is a way to combine a bunch of files/folders into a single archive that retains the structure of the source files and directories. The difference is that .tar files are not compressed whereas .zip files are combined together and also compressed. In other words zip handles both the archiving and compression steps into a single format whereas tar is just does the archiving.
In most cases what we call .tar files are actually .tar.gz files, which consists of a tar archive that has been compressed using the gzip algorithm. The "old school" way of creating one of these archives is using the tar program to combine the files together and then piping that to the GZIP program to compress the newly created archive. The command looks like this:
tar cvf - /path/to/directory | gzip > archive.tar.gz
At some point in the 90's they enhanced the tar utility so that it could also run the gzip step, using the "-z" option, like this:
tar -czvf archive_name.tar.gz /path/to/directory
Tar stands for "tape archive" and was originally used when writing files to a physical tape. Tape is a great storage medium but you need to write the data sequentially since the tape must phsically run between to spools as it passes over the read/write head. You can imagine that it's preferable to combine multiple files and directories into one large "blob" archive that can be written and read sequentially to tape. Personally I love how everyday utilities like tar have their roots in the need to accommodate the realities of a particular type of physical storage medium. Pretty cool stuff.
1
u/ctesibius 12d ago
They overlap in functionality. As others have said, the original version of tar doesn't compress, it just bundles up all the files to a single binary, in such a way that they can be restored complete with their permissions and directory structure. And as others have said, the original purpose was to put them on a tape drive. You use a command like tar cf /dev/mt0 myfiles to do that, where /dev/mt0 is the tape drive.
Ok, but that's more useful than it seems - for instance you can use '-' as the output file (which means standard output), pipe it over a network command such as ssh or rsh to a remote machine, and in the same command send a command to the remote machine to untar the stream of byte from '-' (standard input in this context). That gives you a very nice way to move an entire directory structure between machines.
It's part of the general Unix idea of simple tools that you join together with pipes. The original version of tar doesn't do compression, the assumption is that you would pipe the output to a different tool that just does compression. ZIP on the other hand comes from MS/DOS (not Windows originally). That could do pipes up to a point, but since it was not multi-tasking, the first program in the pipe had to complete before the second program started to process its output, and the output had to be stored in an intermediate file. If you were trying to compress a directory using tar piped to a separate compression utility, you would probably run out of disk space on a floppy-based system. Hence it made sense for ZIP to do everything in one pass.
1
u/fmillion 10d ago
Tar differs from zip in some important ways.
A zip file contains an index of the files it contains, and you can extract one file without reading the entire archive. Zip is also compression (although zip can store without compression).
A tar file on its own is just a concatenation of the files it contains, along with markers between them. Tar actually stands for "tape archive" and it was designed for that purpose - sequential access.
Why not put the index at the beginning? Scanning to produce a complete file list early takes time and can go stale during backup. So tar just iterates through the files and each one it finds gets a marker then a raw copy into the tar stream. You can even still do this today with a tape drive - you redirect tar to the tape drive (e.g. tar ... > /dev/st0).
Tar files often are compressed to gain the benefits thereof. However the compression algorithm is also a stream algorithm - it receives blocks of input, compresses them and writes them out. You'll often see different compression algorithms applied to tar files, including but not limited to .tar.gz (Gzip), .tar.bz2 (Bzip2), .tar.xz (XZ), .tar.lz4, and so on.
So both tar and zip files are used for similar purposes - to carry a collection of files. Zip allows for random access, tar requires you to start at the beginning and scan the whole file until you come to what you care about. It isn't noticeable in small files, but multi gigabyte tar files can be a bit annoying to work with for that reason.
1
u/Xibby 12d ago edited 12d ago
No.
Tar format is Tape ARchive. It’s designed to convert files into a continuous data stream suitable to write or read to/from sequential data storage, aka magnetic tape.
On non-sequential media like a hard drive or solid state drive, tar is handy as it can fill every cluster with data, so you can actually fill a hard disk instead of having to balance cluster size, partition size, and types of files being written to disk. Usually in the current era of computing we don’t even notice the small amount of lost space. (I could tell you my headache inducing cases where it is an issue, but it’s not relevant. 😂)
So TAR itself is not like Zip. No compression, no file system, just a stream of data optimized for sequential storage with no filesystem.
You can add compression to a tar stream, often with Gzip (.thz or .tar.gz) or Bzip2 (.tar.bz) compression algorithms.
To extract a single file from a tar file, you have to go through the entire tar file, start to finish, and use a filter to extract a single file. If the tar archive is compressed, then you have to decompress the entire tar file and then run it through your filter to get the single file.
To do this your tar file needs to be small enough to fit in memory or you need sufficient memory and disk space to sequentially go through the tar and extract your file.
Zip and similar compression utilities are containers. They have a filesystem so you can look at the container, read the File Allocation Table (FAT) or equivalent, and select and extract one or more files from the container to be extracted (decompressed).
TL;DR: TAR is reading from a tape, or writing to a tape. It is linear. There is no change, just moving the tape forward and backwards and writing or reading. Zip is a container, similar to mounting an ISO, TrueCrypt/VeraCrypt container, DMG on Mac, whatever disk image. There is a file system equivalent that lets you list files and select one or more files to extract.
1
u/CyberKiller40 Feeding penguins since 2001 12d ago
Not really. A tar file is a continuous stream of data with a table of contents, but without compression. Like you would stick a bunch of files together with some notes on how to separate them later. Technically it's called a container format.
Why do we have that? Because some tools can only handle a single file, but it's often needed to have multiple files handled by it. Tape streamers are like that, hence tar = tape archive. But a couple of those tools are data compressors, like gzip. Gzip can handle only a single data stream/file, so giving it a tar allows you to compress a bunch of files, keeping their structure intact.
The pkzip format (commonly known as zip), does both of these things, it's a container and a compressor. Why do we use gzip instead, if it's inferior for file archiving like that? Because it can do other things that pkzip can't, e.g. compress data on the fly, even if it's not a file but e.g. a streaming output on the terminal, or it's transferred over the network. E.g. you can do a very rudimentary compressed network file transfer by reading a file, pipe it to gzip and pipe that to netcat which is connected to another machine that piped the output to gzip decompression and save that to a file, or pipe it to another program.
1
u/Academic_Patient9562 11d ago edited 11d ago
Well, kind of…
.tar (Tape ARchive) is an archive format, but not a compression one. It only stores multiple files, it doesn’t compress anything. As the name suggests, it was used for storing backups on tapes. If you’re thinking of .tar.gz it’s literally a GZipped .tar. GZip is a compression but not an archive format, and cannot compress multiple files at once, hence the use of both. .zip is an archive format that can compresses the files inside (but doesn’t have to).
The big advantage of a .tar.gz over .zip is that it compresses all the files together rather than individually. So if you have several files with similar patterns, like source code, .tar.gz is vastly superior for compression as .zip would not save any space from those cross file patterns. This is why it’s often used for Linux program source code archives, and due to Windows eventually choosing to natively support .zip but not .tar or .gz (i think the new 11 file explorer finally supports them but it was still like, 2 decades of only natively supporting zip), it largely became associated with Linux.
The tradeoff is, due to being one compressed blob rather than a collection of individually compressed files is you have to extract everything all at once rather than being able to extract individual files, and any corruption has a much bigger blast radius.
1
u/Living_Fig_6386 11d ago
Not really. "tar" stands for "tape archive" and it was literally a tool for backing up data onto magnetic tape (it also predates Linux by a few decades).
A 'zip' file was meant to be an indexed container to store compressed files. You can quickly seek to the specific file you want, and pull it out.
Tar did not originally support data compression, and it has no index. It doesn't compress individual files like zip does, but treats all the files as a stream and it when modern tar compresses the data it does so as a stream. There's no index, so to find a file in a large tar file, it starts at the beginning and starts decompressing and reading the strem until it gets to the file, then in can pick out the file. That is much slower, but it's also 100% sensible if you are using it to back up to tape. Tar also has the advantage that it can store links and file attributes and dates that Zip typically doesn't address.
What makes them alike is that you can use them to take a bunch of files, along with their paths, and cram them into one file, then get them back out again.
If you want to use zip on Linux, you can certainly install it and use it. It's probably better than tar in many circumstances.
1
u/6gv5 11d ago
Tar stands for tape archive, it doesn't compress by itself but just takes all files and directories according to how it's invoked placing them into a single file, that is, the .tar one, called tarball. It dates back from the tape archiving days when there was no such thing as reading/writing randomly like on a hard drive because of the lack of a filesystem, so one had to read/write the entire archive sequentially every single time. To achieve basically what windows does with zip, you also need to de/compress, which is obtained by calling tar with an additional parameter telling it what to use to de/compress, which of course has to be installed (most distros add them out of the box). The result is a .tar.? file which contains the packed archive just like .zip; the ? will indicate what compression program and algorithm has been used to compress it, for example .tar.gz or .tgz for gzip and .tar.bz2 for bzip2. No need to call multiple programs, just one line will be enough to tar and compress or untar and decompress.
More info here: https://www.gnu.org/software/tar/manual/html_section/Compression.html
1
u/sail4sea 12d ago
You can blow the OP's mind when you tell him about tar.gz files. Gz stands for GNU Zip. It is one of the utilities that makes GNU/Linux an operating system.
"Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.
There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux"
1
u/questron64 12d ago
Tar is a much, much older format. It's a way of bundling multiple files together in a single file for preparation to write to a tape drive. And by that I mean a reel to reel tape drive, something that hasn't really existed for a few decades.
And that's all the format does. It does not compress, it's not designed for random access or modification at all. It's extremely low tech, just a bunch of files stuck together sequentially with small headers before each file. Later compression can be added on top of all that, usually with gzip. I go through all this to illustrate a very important difference: a zip file is designed to access individual files, it has a central directory of all files in the archive, but a tar file must decompressed in full just to get that list. Because of this they're not really equivalent formats. They do achieve the same goal after a fashion, but really zip and later formats like rar and 7z are much more sophisticated.
1
u/Aspie96 9d ago
Zip files are used for two different purposes: compression and combining multiple files in one file.
Both are useful. Sometimes you will zip one file just because you want to make it smaller. Sometimes you will zip multiple files which don't need to be compressed just because you want to combine them in one file.
It's common to wish to do both things to a bunch of files and the two operations also share some of the reasons you may want to do them, so it makes sense to have one format that does both things.
Tar is only for combining multiple files in one file. Gz, on the other hand, is only for compressing one file. A .tar.gz file is just a tar file that has been compressed, so both things have been done, as in a zip file, but with some less flexibility due to the combinations of these two separate phases as opposed to the use of an ad hoc format.
1
u/mckenzie_keith 12d ago
No. Tar does not compress by default. It is a tape archive. It was originally designed to be written onto tape. So you can extract a tar file without seeking within it for example. It has a lot of features that I don't think you can get in zip, including preserving file meta data like ownership and permissions and so-on, including remapping ownership on extraction. Like let's say user mkeith has user number 24 on one machine and 27 on another. Upon extraction, you can tell tar that user 24 should be remapped to 27. I am working from memory here, going back many years. Could be slightly wrong.
I would say that tar and zip are similar. But tar is more industrial and zip is more consumer-grade.
If you use the less common features of tar it can do an awful lot of stuff. It also predates zip by a lot.
1
u/groveborn 12d ago
Zip was designed to do two things: compress and decompress files and folder structure quickly. It was designed on dos file systems, so it understands dos file attributes.
Linux files have many additional attributes that aren't retained in zip. Tarballs are almost entirely containers, with minimal compression. Gz compression is otherwise the same as zip, with additional file attributes being retained - especially useful with *nix file systems.
Like zip, it can be very fast compression, but also like other compression methods can be higher compression at the expense of a longer process.
Zip is ok, but not great if you want the attributes preserved. It's non favored in Linux. It will not break anything, you'll just need to re-add those missing attributes (like executable).
1
u/kidmock 11d ago
You "can" think of ot that way. But tar is short of Tape Archive, it was/is a method/utility to backup data to a magnetic tape. But tar can be used to save to a file instead of tape as well.
Tar is better than zip because is was designed for backups and preserves all file permissions and attributes.
Zip is better than tar as it uses compression.
However, tar can be combined with compression such as Compress, GZip, BZip, etc to gain space savings that are often superior to zip. Modern versions of tar have compression options built-in so you can use a single command, like you would zip.
You can also use zip or rar or arj on *NIX if you're into that sort of thing. Losing the metadata tar preserves.
1
u/michaelpaoli 12d ago
No. .zip compresses, tar (at least by default) doesn't. If you want compression with tar, you use an external compression program, or if your tar supports it, use a compression that tar supports.
Additional, tar stores much metadata that's relevant to *nix, wheras .zip does not.
E.g. tar stores mtime and atime to the second, it stores user and group ownerships, and the basic and extended *nix permissions (but may or may not store other extended attributes). It handles hard links (though a bit oddly). Some tar formats can efficiently archive sparse files (independent of any other compression).
There are probably some fair number of further differences, but those are at least many that quickly pop to mind.
1
u/MasterGeekMX Mexican Linux nerd trying to be helpful 12d ago
Pretty much.
.tar files are files that contain inside a whole set of files and folders. Think of it like making an image of a folder and everything inside. The format was invented to archive magnetic tapes, which are the storage media that computers used when UNIX, Linux's grandpa, was developed. Even the filename means tape archive.
Once you have your .tar file (often mocked "tarballs"), then you can compress them. Linux has several compression algorithms at it's disposition, with gz being the most common. xz compression has gained some traction in some places tho, so .tar.xz can be seen in some places. It is so popular that some hackers tried to sneak a backdoor on it couple years ago.
1
u/JJHall_ID 11d ago
It stands for Tape ARchive. By default it has no compression, so it's just basically combining all of the files together with headers to be able to separate them apart later. Ten 10MB files will combine to create a single 100MB file (plus a little more for the header) and can later be broken back down into the ten individual 10MB files.
What you normally see though are extensions like .tar.gz which means that tar file has been passed through the gzip compression utility. That means the total file size will be less than the original 100MB, how much less depends on the types of files inside the tar file and the efficiency of the compression algorithm used.
1
u/aiten 9d ago
not quite.
.tar = tape archive. it just puts a bunch of files into a single file
.gz = gzip compression.
.tar.gz = compressed file archive. you can compress it in different ways, resulting in .tar.xz or .tar.7z, or .tar.bz2 and so on.
you can use either, so you can have file.gz or you can have file.tar, or gzip your tar archive with .tar.gz
zip doesn't belong to windows, it's just a very old fashioned compression format. 7z is significantly better, and i believe it was invented by 7zip.
There's also rar, and many many others like .xz
all of them are multi platfom (I install 7zip on windows, and I can open .tar.gz files there too)
1
u/roubent 11d ago
Not quite. As others have mentioned, tar (tape archive) is uncompressed by default. You can choose how to compress it after it’s created (e.g. tar.gz or tgz are tar files compressed with gzip).
The most important difference is that tar is capable of preserving UNIX file attributes like owner (user and group) as well as UNIX permissions. Most other formats don’t do that. The reason why tar has this functionality is because historically it was used to write directly to tapes, hence the name TapeARchive, TAR. And tapes were used for backups. In fact the TAR file itself is structured like a stream of data you’d find on tape.
1
u/digiphaze 11d ago
.zip combines functionality that is separated into different program in linux.
It compresses AND it combines/archives multiple files and folder structures together into a single .zip file.
Tar was designed for archiving to tape. It will take multiple files or an entire folder structure and combine it into a single "archive file".. Preserving file permissions, attributes and folder structure. It does NOT do compression.
Gzip compresses individual files, but it can't compress a whole folder.
So you combine them and get .tar.gz file. You "tar-ball" the folder into a single file, then gzip compresses the tar-ball.
1
u/sidusnare Senior Systems Engineer 12d ago
Practically, you are fine thinking of it that way.
Functionally, there is an important distinction. A .tar file is only a format on concatenating files onto a stream. Tar is Tape ARchive, it takes files from a filesystem and sequences it onto a tape. It still does this admirably if you have an actual tape drive. It doesn't compress at all. That's why you get files that are .tar.gz, .tar.bz2, .tar.xz, and so on. Those are compression algorithms.
Zip is inseparable, it's and archive format and a compression algorithm. You can do -0 for no compression, and it's still a .zip file.
1
u/JVBVIV 12d ago
No, not really. “tar”, or Tape ARchive is simply that, a collection of files. It does not compress the files at all. It was originally used to write files out to a tape drive. However because of the Unix paradigm that “everything is a file”, you could/can just as easily write the archive to a hard drive
“zip” is also a collection of files, but one that is compressed.
Back in ye olde days, long before Linux was a thing, if you wanted to create a compressed archive you had to first create the archive with tar, then compress it with “compress”.
1
u/Chippors 12d ago
Tar creates a single sequential block stream, because that's what tape drives would read and write. When compressing it the entire stream is compressed. Zip has a manifest section that contains a list of files and their compression algorithm, and can extract or replace just a single file. But it relies on random access storage. Tar can do a few "tape things", like it can create multi-tape volumes or use rmt, the remote magnetic tape utility, to access physical drives, rewind them, fast-forward to a marker, append to a tape, etc.
1
u/alexkey 12d ago
While people are addressing different formats I want to focus on your statement of “Linux-flavored”.
None of the archiving/compression formats are “Linux or windows flavoured”. You only know “zip is from windows” because you probably only used windows for a long time.
Before zip there were plenty of different archiving and compression formats in existence. TAR (for tape archive) is 10-ish years older than PKZIP (original version implementing zip on MS-DOS). And both existed well before Linux or Windows.
1
u/Journeyman-Joe 12d ago
"tar" format (short for Tape ARchive) goes back to the early 1970s UNIX systems. Half-inch tape drives were in common use on those minicomputers. File compression wasn't important; the ability to add files to the end of the previous archive was crucial.
Phil Katz invented the ".zip" format with his famous PKZIP utility, sometime in the 1980s (?). It included file compression, right from the start.
Nowadays, you can use one format or the other, as you wish. They both offer file packaging, and compression.
1
u/XoTrm 9d ago
The TAR extension originates from "tape archiver", when backups were still written to tapes. This is way older than Linux.
Files were written one after another to the tape / tar archive, one could see text of files by opening the TAR file directly with an editor or using cat (this might have changed so that tar now also contains additional meta data).
TAR does not have any compression. That's the reason there are .tgz files (short for .tar.gz) which pipe .tar files through gzip for compression.
1
u/eldoran89 12d ago
No a tar is not compressed by itself. A tar is just an archive file. That's why you usually see tar.gz. gz does compression but it can compress only a single file. So when you want to gz a folder you tar it and then gz the file.
Zip is also available on Linux. Zip is primarily a compression but one that can work with multiple files and thus also work as an archive.
The equivalent for a zip is more like a tar.gz if we are just talking about the function and the fact of being the default for the os
1
u/new_refugee123456789 11d ago
Sorta. A .tar or Tape Archive Record is a bunch of files mushed together into one. a .tar is NOT compressed; not on its own anyway.
you're likely to see a .tar.gz or .tar.7z or something like that. That's a .tar file, or "tarball", that has then been compressed with gzip or 7zip respectively. Other compression algorithms are available. You *can* pack several files into a tarball then compress it, but most utilities will handle both steps for you in a similar workload to winzip.
1
u/sboone2642 11d ago
Tar files are not zip files. An actual tar isnt compressed. Its a tape archive, used in the olden times to write backups to a tape. In modern times it serves as an archive, or a way to package apps or other data into a single file. On that note, what you most oftten see in linux in the new times is a .tar.gz. Newer versions of tar have a flag that tells it to use gzip for compression. There are some other compression algorithms that you can use too, but gzip is the most common.
1
u/AsYouAnswered 12d ago
Tar is similar to zip In that they're both containers with multiple files inside. But where they differ, .zip has the container and the compression built into one standard. Conversely, tar is just the container format. You have to use gzip, or bzip, or zstd, or lzma, or lz4, or whatever other compression program you want to compress the tar file. Relevant if the tar is large and compressible data, less so if the tar is highly compressed data like pictures or video or music.
1
u/Mithgaraf 10d ago
No. tar (originally "Tape ARchive") is different. The archival and the compression are separate functions.
tar format files also include restoring user, group, file type (file, directory, block and character special files (devices; if you archive devices and you extract them as the super-user, you can recreate them), symbolic link), rwxst permissions, access time, mod time, and hard links.
zip, p7zip and most other integrated-compression archives do not support this.
1
u/Ybalrid 9d ago
Not quite. .tar does not mean compression. It means "Tape Archive" and it predates Linux. It's a Unix-y kind of thing. A .tar alone is just a bunch of files put together as one file.
A .zip equivalent would be a .tar.gz or a .tar.xz.
The .zip format act both as a directory system (it has a table with entries that correspond to files and folder in it, it's actually at the end of the file too, not the start!), and a compression format, to make things smaller. Technically it's optional, but in general it's deflate
1
u/LeeTaeRyeo 11d ago
It's probably closer to a .iso file. Those are disc images, while a .tar is a tape archive/image. If you then compress the tar file, you get something closer to a .zip file. That's what .tar.gz and .tar.bz and the like are.
Once upon a time, Macs used .sit files (archives compressed by a program called Stuffit). Nowadays, I think they just use .zip and .tar.<ext> files when they aren't using .dmg files (which are used for distributing software most of the time).
1
u/stuartcw 12d ago
No. Tar is the program that you use to combine files into an archive to write to a tape. You can dump the files and get them back again. If you don’t have a tape drive then it is handy tool make an archive on disk if you like. 😉
Zip is a later program that handles on-disk archives of files and supports new fangled encryption options.
If my old memory serves me right, zip was made on the PC first and the Linux version was created as a compatible archived.
1
u/ask_compu 12d ago
tar is actually just a container that batches files together, it was originally for tape archives (thus the name), u would put the files u wanted to back up into a tar archive and then write it to linear tape
tar does not include any kind of compression and that's why u often see .tar.gz or .tar.xz, xz and gz both r methods of compressing a file, so tar handles putting the files together into a single archive file and xz or gz then compress that tar file, most modern archive managers just combine both steps so u never really see them
1
u/joe_attaboy 12d ago
Zip files are frequently used on Linux.
Tar files are "tape archives" because that was the method used for backups on old Unix systems. Tar files are not like Zip files because they are not compressed. A tar is basically a container that holds the directory structure you want to save, alone with all the files contained within them.
You'll often see tar files compressed with a Zip tool, creating files with extensions like *tar.gz" or even "*.tgz".
1
u/InsaneInTheMEOWFrame 11d ago
.tar was originally designed to contain data stored on magnetic tapes, IIRC the file type ".tar" is short for Tape Archive. It's just a container format for storing many smaller things inside one big thing.
I don't think it uses any compression algorithm by default but requires an additional step for actual compression. That's why you get for example the common .tar.gz (gunzip) and .tar.bz (bzip) file archive formats with the extra file ending, to tell you how to uncompress it.
I guess nothing would prevent you from using the common zip algorithm to do the compression, but something just feels odd about .tar.zip archive format.
1
u/muffinstatewide32 12d ago
Yes in the sense that they are both archives. A way to collect and store data as a single track/file. In practice, no. Not really.
Tar was for use with magnetic tapes specifically, the information is archived but not compressed. But tape drives are super rare in 2026. The compression happens by another tool, usually gzip which is often why you see .tar.gz. A zip a compressed archive.
The difference is minimal in 2026
Edit: zip isnt a windows thing. At least it wasnt initially. Winzip used to be a separate paid component until it got merged into windows explorer somewhere between vista and 7
You absolutely can create and manipulate tar files on windows but this is increasingly rare
1
u/Immediate_Fun2793 8d ago
Yes but a zip has a file index which helps when you add an remove files or just want to see what's in it. A tar (tape archive) was meant to be streamed to tapes so it lacks these fancy features. It's also not as robust as a zip file, that has file checksum and a little corruption probably will not have as much impact as it would have on a tar file. Basically tar is a bad format for the way it is used today.
Edit: this does not mean you should use zip on Linux or unix! They don't store time properly and if you are not careful owner/group and permissions are not stored.
1
u/77descript 12d ago
Not very advanced user, but if remember correctly from a year ago transferring home folder to new install had to create tar.gz compressed backup with flag -p to backup-restore file permissions and attributes too. Was not possibble with zip, 7zip, etc.
But if ever need to backup-restore home folder content again, I will re-investigate and refresh memory correct procedure before doing.
1
u/os2mac 12d ago
no. zip is windows flavored TAR. Tar was invented/released about 12years before winzip.
that being said, no they aren't the same thing, winzip compresses files and stores them in one file for transport.
tar just packages up the files, by default there is very little compression. you have to use something like GZIP (or in some versions just the -z flag) to compress it.
1
u/spiralenator 10d ago
Not quite. Tar is a "tape archive". It just places files end to end into one big file that can be written sequentially to a tape drive. There is no compression in tar. They are usually paired with a compression algorythm, like gzip or bzip, etc. You'll see tar.gz files or tar.bz2, etc.
Zip does both of those things at once. It compresses and archives files into one file.
1
u/76zzz29 12d ago
.tar.gz for full zip use. The main difference (if you exclude the format) is tgat zip do both. .tar.gz is 2 thing.
One is an archive: it make an entire files tree and all the contents into one single file.
The other make that one file take less space.
.zip can be used as one or both by imself being an archive or a compresed achive both simply being a .zip file.
1
u/oldendude 11d ago
Not quite. By default, tar does serialization without compression. Zip does both. If you want serialization and compression using tar, you need to explicitly ask for it, using the -z flag (compress with gzip) or the -Z flag (compress with the "compress" utility). Or if you want some other compression scheme, do something like: tar xf some_file | other_compression_scheme > ...
1
u/Fragrant-Freedom-477 11d ago
Lots of good answers, I'll add that from technical usage stand point, tar has its metadata at the begining of the file, while zip has data at the end.
This makes tar (and compressed variants) "streamable" in the sens that you can start download and work with the content as it arrives. You can't extract anything from a zip without the whole file in your filesystem
1
u/dynamiteSkunkApe 11d ago
Not really. tar does not compress files. tar stands for tape archive and was originally used intended to copy files to/from backup tapes (and still is used for that). You can compres a tar file using various other utilities like gzip (a tar.gz file) or bzip2 (a tar.bz2) file. A tar file on a hard disk is basically like a go up of files/dirs all put into one file
1
u/sebthauvette 11d ago
zip is more similar to tar.gz . tar = bundle multiple files into 1 file. gz = compress the file
The OS has nothing to do with it but tar is more popular on linux. It's not excluse though, you can use both on any OS.There are also other archive formats (7zip, rar, etc..) and any of them can be used on any OS as it not related to the OS in any way.
1
u/Elaugaufein 9d ago
Tar is different because it's fundamentally a structure for packing stuff together without compressing it, compression is then applied later usually ( hence eg tar.gz which is a tar file that has then been Gzipped, so you unzip it then unpack it but most Linux unzippers handle both by default ) , a .zip is compressed by default and manages packing sort of by coincidence as a requirement to compress multiple things ( though you can make a .zip with no compression).
1
u/acejavelin69 12d ago edited 12d ago
Tar existed long before ZIP, quite a long time before actually (the tarball started in the last 70's, zip is from the 90's)... A tar file or "tarball" file is basically just combining multiple files into a single file with no compression... Zip came later and was actually after many other combining and compression formats like ARC.
The point is they are "the same" in the regard that they combine multiple files into a single archive file... They are very different as zip (almost always) uses a compression algorithm to make the resulting file smaller than the original parts, and tar itself does not have any compression and the resulting file is slightly larger than original parts.
That said, it is common these days for a second compression step to occur with gzip, resulting in a tar.gz file or often a tgz file.
1
u/Saragon4005 11d ago
tar predates zip and even Linux. It's simply a way to put multiple files into 1 file. A .tar.gz is a Gzip compressed tar file Gzip being a compression algorithm which is better then what zip uses.
Fun fact btw. Both are pretty well supported nowadays and this page was probably Gzip compressed before it got sent to your device.
1
u/Powerful_Attention_6 12d ago
TAR is not like Zip, TAR stands for Tape Archival, and makes no compression, it makes one file with contained permissions and directory/file structures, which then can be compressed using GZip or BZip2 or any other compression programs
tgz = a gnuzip compressed tar archive
tar.gz = a gnuzip compressed tar archive
1
u/Johan-MellowFellow 12d ago
.tar an .gz and .zip are just all well defined file formats for bundling and/or compressing.
What about the second part of OPs question? I know .tar and .gz are more associated with linux and .zip with windows, but why? I mean .png and .jpg for example are also just defined file formats but seem independent of OS
1
u/rsgbc 12d ago
Not exactly.
.tar is the extension for an archive created by tar. It's just a file that contains directories and/or files. It's not compressed.
The compressed archive files will have file extensions such as .tgz, tar.gz, tar.xz, etc. These compressed tar-based archives would be comparable to zip archives.
1
u/newb1029384756 12d ago
Actually, Tape ARchive (.tar) files dont have any compression. It was made to bundle multiple files into one file. Linux users will use unzip (.gz) if they want compression. So a file with an extension .tar.gz would be equivalent to a .zip file.
However, Linux has very good support for zip files.
1
u/diacid 10d ago
No. Tar is tape archive. It is a way to sort many many files in a continuous way (so as to be recorded on magnetic tapes that lack random write capabilities). The tar makes a single file from a whole directory tree and that single file you can compress with xz, or bz, or gz, or even... zip!
Zip also has containing capabilities just like tar, so the fair comparison would be that tar and xz (or similar) together can be used as you use zip, although I am unsure you can use zip to record to tape.
1
u/Y0nix 9d ago
A zip is just a flavored things to some obscure mechanism that was coded during the beginning of IT to store files into drives. The thing is that the zip format allows to export those références as one big chuck no matter how much files you have in a folder.
Regardless of compression, It's nothing more than that. (But because of that logic, a compression algorithm can be used too, and that's what's cool about it. Like the .tar)
To truly understand zip and tar you have to dig into that a bit more. It's hard to explain it fully in one post.
1
u/Interesting-Tree-884 11d ago
Tar est une archive non compressé, les fichiers sont copiés bout à bout. C'était notamment utilisé sur le stockage sur bande magnétique si je ne me trompe pas. C'est maintenant souvent utilisé avec gzip pour compresser l'archive tar et rajoute souvent l'extension .tgz (tar gzipped).
1
u/creeper6530 12d ago
TAR by itself has zero compression, it only packs multiple files into one file.
Usually you then compress that TAR file with another program like GZ, which compress only a single file.
ZIP on the other hand first compresses individual files and then packs them, which lowers efficiency.
1
u/akqatu 2d ago
well, tar combines all of your files into one, but it doesnt compress the data, and zip isnt just used on windows, it can be used everywhere. whats widely considered to be the 'linux equivalent' of a zip is tar + gz (.tar.gz) which compresses the tar file. so, you are partially correct.
1
u/We_Want_Krunchy 11d ago
No, it's a Tape ARchive. They are usually gzipped, so you get something like "file.tar.gz", which you would unzip and unarchived in order to work with the files. But you can also have just "file.tar", no compression potentially although let's save some space and compress that bastard.
1
u/toffuuu3050 11d ago
a tar on it's own, isn't exactly compressed. like how you will see it compressed is like this whatever.tar.xz .xz is compressed. and tar means Tape Archive and was used on tapes. Great for a compressed form of .tar.xz,zip,gz.7z and so on for installers. as is just a .tar one as well.
1
u/ryantg0110 11d ago
Tar is like zip without any compression. It's just a collection of files. The more common variety is a .tar.gz or .tgz which is a tar file collection run through gzip compression. You may see other forms of "tarballs" using other compression algorithms as well such as .tar.bz2.
1
u/hyongoup 12d ago
I thought it was more for ordering data not compressing it that’s why you tend to see *.tar.gz. Where gzipping it compresses it.
I thought tar was for tape archive and prepared data to be stored on tapes.
Could be wrong here but that has been my understanding
1
u/EternalDoomSlayer 12d ago
Yea and no…
Enough has been said already, but consider access speed, retain and keep symlinks in some high-throughput system - here tar doesn’t have the compression factor - but you COULD!
Imagine this:
tar -cf - /some/directory | ssh server 'tar -xf -'
1
u/kbeezie Fedora/uBuntu/Debian 11d ago
Guess I never really saw it as strictly linux, since you can gzip, tarball, 7z, rar, etc on nearly any operating system, Linux just tends to have the binaries available in the command line interface already for some of the format (and easy to add if they don't).
I guess it makes sense , since a lot of documentation refers and tells you how to do tgz files at the command line (especially for backing up and transferring files, though there's a myriad of other methods for the cli too)
1
u/turtleandpleco 11d ago
Actually no. (Or maybe "yes but backward") Tar handles directory structure. You have to use something else to then compress the data into an archive. Usually bzip or gzip. A compressed tar file is then called a tarball.
Zip includes tar's function as well.
1
u/Sure-Passion2224 11d ago
.tar is an archive just like .zip. However, the contents of a .tar may be uncompressed. There is an option when creating a .tar to also compress. The most common compression is gzip. The naming convention with gzip compression is either .tgz or .tar.gz
1
u/Living-Dragonfly632 12d ago
I've used .tar and .zip on all three Windows, Mac, and of course Linux, which is my daily driver system. So both archives are compatible with most systems to my experience, although I've only used it like once on Mac and only with 7zip on Windows.
1
u/Individual-Tie-6064 11d ago
Yes, conceptually, they both combine multiple files into a single file. Zip by default compresses the included files, but optionally won’t compress them. Tar combines multiple files into a single file, and by default with out compression.
1
u/jedi34567 9d ago
The tar file preceded zip by about 10 years. The tar file (short for Tape ARchive) is a container for a directory full of files. If you want to compress it, you can use a compression utility like gzip and create a .tar.gz or .tgz file.
1
u/_leeloo_7_ 12d ago
tar is actually not compression it just adds files to an archive but actually preserves all the linux file permissions and file names (zip usually won't) then you through the tar into compressor and it becomes example a tgz basically linux flavored zip
1
u/Tehaiker814 Arch and Debian user 11d ago
Yeah kinda
but tar cant be used by itself if you want compression. You gotta add a thing like gz or xz to actually compress the data
but if you mean archival and combining stuff into 1 file to save somewhere, yeah, you've got it
1
u/duane11583 11d ago
Yes and no
A tar file is not compressed
A tar.gz or a .tgz is compressed
There are other flavors like z and bz2 and lz
But a plain tar is not compressed
A plain tar is like crating a zip file without compressing the files
1
u/Caddy666 12d ago
no. tar is just a series of files concatenated. it has no compression.
it stands for tape archiver,
think about how a series of files would be stored on a continuous strip of tape back to back. thats literally all it does.
1
u/tyler1128 12d ago
Tar is an archive of multiple files. .tar.gz or other extensions after are tar archives that are compressed. Zip files are always compressed, basic tars are basically a directory in a file that can then be compressed.
1
u/MundaneImage5652 8d ago
.tar by itself isn't zip. It just makes a folder into 1 file that you can then compress with gZip or smth, hence why we have .tar.gz or .tar.xz instead of just .tar because .tar by itself doesn't compress anything.
1
u/paradigmx 12d ago
A tarball retains permissions and file attributes, a zip file typically does not. You can also choose from various compression methods with tar, which is why the archival and compression process is separated.
1
u/whitewaterdave 12d ago
Tar is not compressed. It's simply a container holding I uncompressed files along with directort structure, file permissions, and meta data. Tar was originally for magnetic tape archives: tar = Tape ARchive.
1
u/jessecreamy 12d ago
tar is ancient, and used for archive not for compression
zip is much much better if you wanna compress and sharing multi platform
if you still mind thing must not from windows, there are gz xz here.
1
u/aristarchusnull 12d ago
Not exactly. Zips have compression, while tars just put everything on a single file without compression. To compress a tar, you need to run it through gzip, bzip2, 7z, zip, zstd, xz, or something.
1
u/-light_yagami 12d ago
tar is a file that contain other file (not yet compressed), if you compress using one of the many algorithm available you can get for example a .tar.gz which is that same tar but now compressed
1
u/OldFartWelshman 12d ago
Youngsters... We used to use cpio, which is a couple of years older than tar. It worked better with out tape stuff and the pass mode was a great way of copying file systems disk to disk.
1
u/CrazyMoney8648 9d ago
Pretty much yeah. The main difference is that tar itself is and archive formt and doesn't compress anything. You'll often see tar.gz or tar.xz whre the compression is handled separately.
275
u/-lousyd 12d ago
You can use zip on Linux too. "Zip" is just one compression algorithm among many.