0

I recently compressed a tar.gz file and thought that I can compress it down further by compressing the tar.gz file into a new one.

What I ran to compress it:

tar -czvf world.tar.gz world/

Then I did:

tar -czvf world.tar.gz world.tar.gz

Now I cannot extract it using the normal command because it gives this error:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
3

The command to decompress tar.gz file is:

tar xzvf filename.tar.gz

Since in your case the original filename and the compressed filename are the same, you can't decompress the file in the same directory you have the compressed file (as it will override it).

Try the following:

  • make a new dir in /tmp
  • copy the tar.gz to that directory
  • change directory to /tmp
  • decompress the file to /tmp

The commands:

mkdir /tmp/myfolder
cp world.tar.gz /tmp/myfolder

cd /tmp
tar xzvf /tmp/myfolder/world.tar.gz

Note: You can run the file command in order to check if the file is actually a tar.gz file

file filename.tar.gz
  • I tried that, it extracted the tar.gz file, but now its giving me that error when running that command again – Alex Mercer Jul 9 '17 at 8:51
  • Alright, I ran the file command and it came back with the file being data, how can I fix that? – Alex Mercer Jul 9 '17 at 8:54
  • @AlexMercer - for the problem of original-filename is the same as output filename, you might need to do it in a different folder. try the suggested solution in my answer – Yaron Jul 9 '17 at 8:58
  • Just tried that, and having same issue where the filetype is data rather than gzip – Alex Mercer Jul 9 '17 at 9:02
  • @AlexMercer - it seems like the file you are try to decompress is corrupted. Do you still have the original directory, or the original tar.gz file which you compressed again using the same name? – Yaron Jul 9 '17 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.