161

I created .tgz file with tar czvf file command.then I ended up with a tgz file. I want to know the difference between it and tar.gz.

mko
  • 21,334
  • 49
  • 130
  • 191
  • Well you could simply try un-gz-ing it. If the result is a working tar file, then there's no difference. – Wormbo Jul 18 '12 at 05:47

5 Answers5

253

I think in the old package repo days, .tgz was used because files on DOS floppies could only have three letter extensions. When this limitation was removed, .tar.gz was used to be more verbose by showing both the archive type (tar) and zipper (gzip).

They are identical.

Tommy
  • 12,588
  • 14
  • 59
  • 110
49

There's no difference at all. .tgz is simply shorthand for .tar.gz.

20

One difference is that browsers seem to have trouble with .tar.gz sometimes, for example, when downloading such a file that already exists locally, it can happen, that they rename it to .tar-1.gz, which will then create problems with certain archivers, mostly on Windows and other environments that use filename ending for file type designation.

This doesn't happen with .tgz ending.

adsc
  • 397
  • 3
  • 9
  • 4
    One additional annoyance with tar.gz is that some decompression apps do not automatically unpack the archive and first create an intermediary x.tar file from x.tar.gz and make you unpack x.tar to get what you need. (Of course if what you need is the archive file itself then this is a perk.) – Halil Sen Nov 24 '16 at 16:47
  • this is a typical file renaming to avoid overwriting, it adds (-1) before the last dot (.) because typically what comes after the last dot is the file extension. – MMSs Dec 23 '19 at 11:12
  • @MMSs Thanks, your comment inspired me to clarify that the problem occurs mostly in environments that use filename endings to designate file type. – adsc Mar 03 '20 at 14:28
5

You can unzip tar.gz or .tgz with:

tar -xzvf

and create with:

tar -czvf

It is absolutely the same

Brian Stamper
  • 2,143
  • 1
  • 18
  • 41
Albert
  • 61
  • 1
  • 1
1

Short answer: there is no difference.

Long answer:

  • SunOS USTAR tar format: tar doesn't support inline compression from options (you can install gtar to have GNU version).
  • Linux POSIX tar (GNU) format: tar can archive and compress as well.

Generally speaking: the extension name will differ depending on how you create your outcome file:

# Archiving THEN compressing: from SunOS or Linux:

$ tar cf output.tar /path/to/archvieme/
$ gzip output.tar
# creates "output.tar.gz" file.

# Archiving AND compressing: people usually save on typing and go with .tgz rather than .tar.gz:

# works only with GNU tar:
$ tar czf output.tgz /path/to/archiveme/

# works on SunOS and Linux:
$ tar cf - /path/to/archiveme/ |gzip > output.tgz
amized
  • 337
  • 2
  • 5