Extracting a tar.gz file returns, “This does not look like a tar archive.”
Looking at the error you are seeing coupled with the fact that you can indeed decompress it says that the file is a genuine TAR/Gzip archive, but perhaps not an immediate TAR is created after the Gzip.
Meaning, if you downloaded this from a web server, sometimes Gzip compression get’s applied to web content on the server level to speed up content download. But if not properly set on the server to ignore already compressed content such as this, it can inadvertently double-Gzip files.
With that in mind I would see if simply un-Gzip it from the command line to see what happens. Use a command like this:
gzip -d ldtp_3.5.0.orig.tar.gz
And see what the resulting file is. I have a funny feeling after you run that command, you will not see a ldtp_3.5.0.orig.tar
in the directory but rather a file named like the source—ldtp_3.5.0.orig.tar.gz
— but perhaps with modification changed? If that is the case it is truly double-Gzipped. So at this point—after that initial un-Gzip—you can run the tar
command you have like this:
tar -xvzf ldtp_3.5.0.orig.tar.gz
And it should now properly decompress the full TAR archive.
Another way of doing something similar to that two step process is to pipe the output of gzip
to tar
like this:
gzip -dc ldtp_3.5.0.orig.tar.gz | tar -xvzf -
The c
in the gzip
as well as the -
at the end of the command is the key:
- The
c
option forgzip
will tellgzip
to decompress to the standard output stream. - The
-
at the end of thetar
command means “use standard input.” So coupled with the the-c
ingzip
, the pipe will then take the standard output stream piped to it fromgzip
and connect that to standard input intar
.
Related videos on Youtube
TheRookierLearner
Updated on September 18, 2022Comments
-
TheRookierLearner over 1 year
I have a tar.gz file and I want to extract it using terminal. I used following commands:
tar tvzf ldtp_3.5.0.orig.tar.gz
andtar -xvzf ldtp_3.5.0.orig.tar.gz
. However, I get the same result for both the files:tar: This does not look like a tar archive tar: Skipping to next header tar: Exiting with failure status due to previous errors
I output of the file command shows its a gzip file:
$ file ldtp_3.5.0.orig.tar.gz ldtp_3.5.0.orig.tar.gz: gzip compressed data, from Unix
I can extract it using Right-click --> Extract but I want to do that using terminal. Can anyone tell me how to do that?
-
TheRookierLearner over 9 yearsI tried the first command
gzip -d ldtp_3.5.0.orig.tar.gz
and I (oddly) got a.tar
file. However, when I triedtar -xvf ldtp_3.5.0.orig.tar
I got an error saying:tar: v: Cannot open: No such file or directory tar: Error is not recoverable: exiting now
-
Giacomo1968 over 9 years@TheRookierLearner Then what happens if you were to do
gzip -d ldtp_3.5.0.orig.tar
on theldtp_3.5.0.orig.tar
? -
TheRookierLearner over 9 yearsI tried
gzip -d ldtp_3.5.0.orig.tar.gz
and I got the messagegzip: ldtp_3.5.0.orig.tar: unknown suffix -- ignored gzip: on.gz: No such file or directory gzip: the.gz: No such file or directory gzip: ldtp_3.5.0.orig.tar: unknown suffix -- ignored
. After this I triedtar -xvzf ldtp_3.5.0.orig.tar
and it worked! Thanks a ton!