I was able to archive and compress a folder with the following command:

tar -cvfz example2.tgz example1

I then removed the example1 folder and tried to unpack the archive using this command:

tar -xvfz example2.tgz 

and tried

tar -zxvf example2.tgz 

Niether of these commands worked. The error returned was:

gzip: example2.tgz: not in gzip format
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

It clearly used gzip compression since I passed tar the z qualifier in the initial command. What am I doing wrong? I am on Ubuntu 14.0.4

  • Minor comment. You wrote tar -cvfz example2.tgz example1. Aside from the syntax issue (as others have said, flag order is significant here), did you really mean to write example1 there? Sep 4, 2014 at 12:39

2 Answers 2


The command you're showing in your first line (tar -cvfz example2.tgz example1) doesn't work and it should not output any file example2.tgz. Didn't you get an error? Perhaps the file example2.tgz existed already? Check if you have a file called z in that folder - that's where the tgz has been saved to, because:

The -f parameter specifies the file which must follow immediately afterwards: -f <file>


tar cvzf exam.tgz example1
  • No, on initial creation I did not get any errors and the example2.tgz file was placed into my home directory. I did not already have a file with that name. What is max.dat and what does it do?
    – user53029
    Sep 4, 2014 at 11:53
  • well that just went away that's strange
    – user53029
    Sep 4, 2014 at 11:54
  • that was a unintential copy paste error on my side, it's corrected already.
    – Sebastian
    Sep 4, 2014 at 11:54
  • can you confirm you have a file z in your folder?
    – Sebastian
    Sep 4, 2014 at 11:55
  • I did have some z files in there. They only showed up after I ran the extraction command with subsequent failures. However, after following your instructions and placing the "f" param last in the sequence, I can now unzip the .tgz file. Thanks for the help Sebastian :)
    – user53029
    Sep 4, 2014 at 12:31

just to precise, creation

tar cvzf example2.tgz example1


tar xvzf example2.tgz


  • c : create
  • x : extract
  • v : verbose
  • z : compress
  • f : target tar/tar gz file argument, sould be placed last

the trick is that f is expecting a file, which should be next.

  • yeah, my Linux study guides fail to mention that small but crucial detail lol
    – user53029
    Sep 4, 2014 at 12:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .