r/linuxquestions • u/RubyRiolu • Oct 08 '26
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
303
Upvotes
278
u/-lousyd Oct 08 '26
You can use zip on Linux too. "Zip" is just one compression algorithm among many.
288
u/graph_worlok Oct 08 '26
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.
66
u/Beginning_Earth_9702 Oct 08 '26
It stands for Tape Archive, originally designed for writing data to magnetic tape drives. It is not compressed.
98
u/RMtz97 Oct 08 '26
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"
11
u/bigntallmike Oct 08 '26
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.
5
u/konqueror321 Oct 08 '26
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/Nekomancerr Oct 08 '26
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 Oct 08 '26
Tar doesn't provide compression by default. But yeah it's okay to pretend they are the same for the most part.
3
u/PseudoFrequency Oct 08 '26
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 Oct 08 '26
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.
3
u/kudlitan Oct 08 '26
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 Oct 08 '26
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.
4
u/BitOBear Oct 08 '26
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.
2
u/cmdPixel Oct 08 '26
No
1
u/Radiant-Meteor Oct 23 '26
I doubt .zip is associated with Windows, and .tar is not associated with linux either. Plus .tar doesn't compress anyways, its the extension after that which represents compression. You'd see .tar.gz for a tarball etc.
1
u/OutrageousCrab9224 Oct 08 '26
No but kinda and you can think of it that way if you like
1
u/Johan-MellowFellow Oct 08 '26
.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/paradigmx Oct 08 '26
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/rsgbc Oct 08 '26
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/aristarchusnull Oct 08 '26
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/ask_compu Oct 08 '26
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/sidusnare Senior Systems Engineer Oct 08 '26
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/Living-Dragonfly632 Oct 08 '26
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/questron64 Oct 08 '26
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/mckenzie_keith Oct 08 '26
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/Journeyman-Joe Oct 08 '26
"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/michaelpaoli Oct 08 '26
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/raptir1 Oct 08 '26
tar files do not apply any compression. They simply combine multiple files into one.
1
u/os2mac Oct 08 '26
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/lnxrootxazz Oct 08 '26
zip works on Linux as well. But basically yes. Using tar is much more common on Linux and you can compress archives using tar + xz or bz2 for instance
1
u/alexkey Oct 08 '26
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/MasterGeekMX Mexican Linux nerd trying to be helpful Oct 08 '26
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/groveborn Oct 08 '26
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/Xibby Oct 08 '26 edited Oct 08 '26
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/77descript Oct 08 '26
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/tyler1128 Oct 08 '26
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/muffinstatewide32 Oct 08 '26
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/jessecreamy Oct 08 '26
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/Angelworks42 Oct 08 '26
Kinda no tar files aren't compressed.
1
u/cklaubur Oct 08 '26
I think a .tar would be closer to a .iso than a .zip.
1
u/skettiSando Oct 08 '26
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
.tarfiles are actually.tar.gzfiles, 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.gzAt 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/directoryTar 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/ImpressiveHat4710 Oct 08 '26
Zip predates windows.
1
u/bsensikimori Oct 08 '26
A tar (tape archive) doesn't compress, you're thinking if a tar.gz, or .tgz
1
u/ellenor2000 Oct 08 '26
Culturally, yes.
In terms of the file format, hell no. As others have explained, .tar.gz is a tar archive (non-compressed) to which gzip compression has been applied to the whole.
1
u/mecshades Oct 08 '26
Tape archive. It globs multiple files together in a single, contiguous file and doesn't necessarily mean compression. A .tar.gz is a gzipped tar file.
1
u/Tahionwarp Oct 08 '26
tar is more -= its a tape archiver, if you have a tape drive it has all the needed functionality.
also it can have relative or absolute paths, preserve permissions etc..
1
u/_leeloo_7_ Oct 08 '26
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/flumphit Oct 08 '26
Tape ARchive format is from the late ‘70s, so is around ~2x as old as Linux.
1
u/zed_patrol Oct 08 '26
How has nobody dropped this yet:
https://imgs.xkcd.com/comics/tar.png
1
u/EternalDoomSlayer Oct 08 '26
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/PowerSilly5143 Oct 08 '26
I prefer 7z
1
u/sail4sea Oct 08 '26
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/Competitive_Swan_755 Oct 08 '26
tar = tape archive
1
u/serverhorror Oct 08 '26
Both are formats to put one or multiple files in a "container".
Notable difference: Zip has compression while tar doesn't.
1
u/creeper6530 Oct 08 '26
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/OldFartWelshman Oct 08 '26
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/AsYouAnswered Oct 08 '26
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/76zzz29 Oct 08 '26
.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/-light_yagami Oct 08 '26
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/eldoran89 Oct 08 '26
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/stuartcw Oct 08 '26
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/gdmzhlzhiv Oct 08 '26
Tar is not compressed
1
u/blackbasset Oct 08 '26 edited Oct 08 '26
Theyre all file formats for archives, often compressed. There is a whole bunch of others as well. That's like saying "odt is just like a foss flavoured docx, yeah?"
1
u/ctesibius Oct 08 '26
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 myfilesto 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
sshorrshto 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
tarpiped 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/Caddy666 Oct 08 '26
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/Chippors Oct 08 '26
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/Powerful_Attention_6 Oct 08 '26
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/Busy_Necessary1477 Oct 08 '26
Nope, quite wrong. But you are free to stay uneducated and believe whatever you want.
1
u/newb1029384756 Oct 08 '26
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/These_Pin8618 Oct 08 '26
Tar does not compress. Just joins the file into a neat tar ball
1
u/Charming-Designer944 Oct 08 '26
A .tgz or .tar.gz is a very close match to zip.
A tar file is an uncompressed archive. Combined with compression like gzip and you get a compressed archive very much like zip.
1
u/radek432 Oct 08 '26
No, tar by default is not compressed. It simply gathers multiple things in one file.
1
u/Level_Working9664 Oct 08 '26
It's the other way around. Tar was around before zip.
1
u/JVBVIV Oct 08 '26
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/DeaconPat Oct 08 '26
The pedigree goes the other way, zip (in all the variants) is the windows tar file. *nix systems were using tar before the IBM PC was marketed.
1
u/CyberKiller40 Feeding penguins since 2001 Oct 08 '26
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/razorree Oct 08 '26
tar is an archive/container, but without compression. it just "combines" files into one.
1
u/buttershdude Oct 08 '26
No, .tar is not inherently compressed. .zip is.
1
u/burlingk Oct 08 '26
A tar file is not a zip file. It's an archive file and not compressed.
That is why you have to use flags to tell it to run it thought a compression program.
1
u/JohnVonachen Oct 08 '26
Tar is tape archive. It’s how you combine n number of files into a single file. Then you compress/encrypt the tar so not only is it smaller to transmit but is more secure.
1
u/deekamus Oct 08 '26
IIRC, .tar is more of a "file combiner". It makes a group of files into one monolithic file (which is useful). This is why it's often paired with a "file compressor".
1
u/hyongoup Oct 08 '26
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/ConcreteExist Oct 08 '26
With a program like 7zip you can open tar files on Windows as well, they're just compression algorithms.
1
u/joe_attaboy Oct 08 '26
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/acejavelin69 Oct 08 '26 edited Oct 08 '26
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/kbeezie Fedora/uBuntu/Debian Oct 08 '26
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/FuggaDucker Oct 08 '26
No. I cant believe all of the yestards here,
Zip is compressed.
Tar is not.
Tar,gz is but that is a gzipped tar
Linux treats zipping in two phases. Tar, then zip.
We do it in one command but they are two distinct things.
1
u/GreenSouth3 Oct 08 '26
they are all just compression protocals
1
u/Individual-Tie-6064 Oct 08 '26
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/NaturalTechnician737 Oct 08 '26
It's closer to the file saying "the data in me is structured like songs on a cassette tape"
1
u/ryantg0110 Oct 08 '26
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/sebthauvette Oct 08 '26
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/LeeTaeRyeo Oct 08 '26
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/just_some_guy65 Oct 08 '26
Tar combines files, not compression - which is useful if you just want one object rather than many and either compression doesn't matter or the files are incompressible.
1
u/Academic_Patient9562 Oct 08 '26 edited Oct 08 '26
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/oldendude Oct 08 '26
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/dynamiteSkunkApe Oct 08 '26
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/mikeegg1 Oct 08 '26
No.
1
u/digiphaze Oct 08 '26
.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/Puzzled_Baseball_100 Oct 08 '26
Tape archives predate zip. Both are archives and both can be used on Linux or Windows.
1
u/caveat_cogitor Oct 08 '26
tar is just bundling multiple files/folders into a single file, not necessarily compressed. A .tar.gz would be tarballed and compressed
1
u/Living_Fig_6386 Oct 08 '26
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/jkpetrov Oct 08 '26
Tar AFAIK = Tape Archive. Bundle files into one. tar.gz is closest to zip
1
u/Fragrant-Freedom-477 Oct 08 '26
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/xpusostomos Oct 08 '26
basically yes, it was invented to stream your data to a tape drive, but can stream it to a file also.
1
u/clearclaw Oct 08 '26
And nobody mentions
cpioas the other base/standard way of creating archive files in Linux?1
u/6gv5 Oct 08 '26
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/Narrow_Victory1262 Oct 08 '26 edited Oct 08 '26
tar is actually from "ar" -- the archiver. and the t stands for tape.
ar was invented in 1971. tar in 1979
1
u/0HAO Oct 08 '26
a zip file is more like a tar file, since the tar file came first.
1
u/maineac Oct 08 '26
Actually a tar file is just a bunch of uncompressed files in a package. While a tar.gz is actually compressed like a zip file does. Ga is the compression program. Tar is a bundling program.
1
u/turtleandpleco Oct 08 '26
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/WentThisWayInsteadOf Oct 08 '26
No, tar is a ball of files. If you want zip then use zip. You can create a compressed tar; tar.gz or tar.gz2 - most people do tar.gz (gnuzip).
1
u/duane11583 Oct 08 '26
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/B_A_Skeptic Oct 08 '26
Yes, but a tar is not compressed. That is why you will often see a tar.gz file, which is a tar that is then compressed with the gzip.
1
u/temporary_dennis Oct 08 '26
No.
Tar is simply a way to put several files and directories into one file...without compression.
1
u/Saragon4005 Oct 08 '26
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/kidmock Oct 08 '26
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/JJHall_ID Oct 08 '26
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/nanoatzin Oct 08 '26
TAR is a disk image and not just compression.
1
u/unspoiled_one Oct 08 '26
Du kannst auch ein xlsx oder docx in zip umbenennen und reinschauen 😉
1
u/nshire Oct 08 '26
Tar is an archive, it doesn't natively compress
1
u/new_refugee123456789 Oct 08 '26
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/AutofluorescentPuku Oct 09 '26 edited Oct 09 '26
In the traditional *nix world, .tar files are essentially a .zip with no compression. A .gz file is compressed. A .tar.gz file is both, sequentially.
These days .zip is much more common.
Edit: clarity.
1
u/JonBovi_msn Oct 09 '26
TAR is an archive originally meant to stored a set of files on tape. The TAR is often compressed by gzip to be a tar.gz .
1
u/Tehaiker814 Arch and Debian user Oct 09 '26
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/roubent Oct 09 '26
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/bigtreeman_ Oct 09 '26
tar just stores multiple files into a single file,
tar with option -j bzip2, -J xz, --lzip lzip, --lzma lzma, -lzop lzop, etc, compression options
1
u/toffuuu3050 Oct 09 '26
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/sboone2642 Oct 09 '26
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/Interesting-Tree-884 Oct 09 '26
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/We_Want_Krunchy Oct 09 '26
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/daddyd Oct 09 '26
i never associated compressed files to any os, i don't think there are any such files that only work on one os. even on dos you had so many formats, zip was one i even didn't use that much.
1
u/[deleted] Oct 09 '26
.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/Sure-Passion2224 Oct 09 '26
.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/VulcarTheMerciless Oct 09 '26
Everyone is getting lost in the minutia... the simple answer to your question is yes.
1
u/KendaJ99 Oct 09 '26
tar isn't compressed. TAR stands for tape archive, its only purpose it containing multiple files in one file. to compress it you then use gzip, that's why you see .tar.gz everywhere
1
u/diacid Oct 09 '26
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/cormack_gv Oct 09 '26
They're both containers. tar predates zip by a lot. You can use either on any system. Or rar or 7zip, etc.
1
u/jo-erlend Oct 09 '26
No, tar only turns multiple files into one, hence the term "tarball". There's no compression. So you first wrap files into a tarball, then add compression of some kind to it.
1
u/spiralenator Oct 09 '26
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/Mithgaraf Oct 09 '26
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/Business-Activity-99 Oct 09 '26
No.
1
u/Fun_Jump_1445 Oct 09 '26
Well… I guess, but a tarball doesn’t have to be compressed. All zip files are compressed. But yeah, they’re used about as ubiquitously in Linux as zips are in windows
1
u/fmillion Oct 09 '26
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/onepaulkrause Oct 10 '26
Oh compression 🤦♂️
1
u/Stock_Sugar3707 Oct 10 '26
.tar is just one part of the full compression algorithm. Don't forget .gz. But this works on all platforms, including .zip.
1
u/Y0nix Oct 10 '26
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/XoTrm Oct 10 '26
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
.tgzfiles (short for.tar.gz) which pipe.tarfiles through gzip for compression.1
u/Primary-Purchase-153 Oct 10 '26
.tar means Tape ARchive. It is standarized container created for preparing files to backup on streamers. Nowadays it is usually used with compression.
1
u/aiten Oct 10 '26
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/Ybalrid Oct 11 '26
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/jedi34567 Oct 11 '26
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/Aspie96 Oct 11 '26
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/Elaugaufein Oct 11 '26
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/Historical_Cost6752 Oct 11 '26
tar by itself doesn’t compress.
1
u/goon12 Oct 11 '26
Tar files are archives, that can be compressed
1
u/irshadali5 Oct 11 '26
If I'm right .tar is archiver?
1
u/Dazzling-Read1451 Oct 12 '26
No filter.
1
u/MundaneImage5652 Oct 12 '26
.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/IncredibleBihan Oct 12 '26
Compression
1
u/akqatu Oct 17 '26
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/Suspicious-Craft-754 Oct 26 '26
A tar file is just a container but it can be zipped. Some zip packages can't zip directories so you put the files in a tar first.