I have recently begun using a VPS and am learning linux along the way. I have compressed a folder using tar, then I gzipped it and used scp to send it to my server. When I decompress using tar -zxvf .tar.gz, all of the files within the folder still have .gz . Am I compressing the folder wrong to begin with?


Is it possible that you first gzipped the files inside the folder, then used tar and then again gzipped the tar file? Something like this:

gzip folder/*
tar -cvf folder.tar folder
gzip folder.tar

If yes - the first gzip was too much. You should simply do:

tar -cvf folder.tar folder
gzip folder.tar

Or even simpler

tar -cvzf folder.tar.gz folder
  • Not sure how, but it looks like that is exactly what I did. Thanks for the quick response. – mikeyrocks Apr 13 '11 at 13:02
  • ...and the command to extract this file is tar xvzf folder.tar.gz. v = verbose (print the names of the files as they are extracted), z = gzip file and f folder.tar.gz specifies the file. See the manual page on tar. – Lekensteyn Apr 13 '11 at 13:14

Yes, you are compressing the folder wrong to begin with. You can do it correctly all in one step like this:

tar cvfz tarfile.tar.gz folder/
  • Will definitely use this single step in the future. Appreciate it. – mikeyrocks Apr 13 '11 at 13:02

Try a "tar -tvzf" on your archive and check if the files inside the archive are individually gzipped from their file names. It's the only way I can think of that might make this happen, although I'm not sure how you would have gzipped each file while compressing.

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.