.tar vs .tgz...what is the difference?

command-line, tar

Solution

Absolutely no difference. A filename is just a filename. Usually, when you use the `tgz` form, it's to indicate that you've gzipped the tar file (either as a second step or using the `z` flag):

tar zcvf filename.tgz {filenames}

or

tar cvf filename {filenames}
gzip -S .tgz filename

`.tar`, on the other hand, normally means "this is an uncompressed tar file":

tar cvf filename.tar {filenames}

Most modern tar implementations also support the `j` flag to use `bzip2` compression, so you might also use:

tar jcvf filename.tar.bz2 {filenames}

Problem

So I was just archiving an assignment for email submission, and was asked by the instructor to do so using the tar command and create a .tgz file, which I did with the following command line script: ``` tar -cvf filename.tgz {main.cpp other filenames here} ``` No problems on the archive or anything, but when I went to email the file, gmail prevented me saying that my file contained an executable (I'm assuming main.cpp?), and that this was not allowed for security reasons. So, I ran the same script, but this time created a .tar file instead, like so: ``` tar -cvf filename.tar {main.cpp filenames here} ``` Again, archives just fine, but now gmail is fine with me emailing the archive. So what is the difference? I've only really used tar for this purpose, so I'm not really familiar with what the different extensions are utilized for. Obviously, I've figured out a way to get the functionality I need, but like all tinkerers, I'm curious. What say you?

Original source