How to solve: This does not look like a tar archive

Problem:

Sometimes compressed files are not what they look from the extension. Recently I downloaded a .tar.gz file (say, we call it as filename.tar.gz) but when I tried to extract it, it gave error. It went something like this:

command: tar xvzf filename.tar.gz 
output: tar: This does not look like a tar archive 
tar: Skipping to next header 
tar: Exiting with failure status due to previous errors 

Reason:

The error says it all. This does not look like a tar archive. What does it look like than? The way to find it out is using “file” command in the following manner:

command: file filename.tar.gz 
output: filename.tar.gz: gzip compressed data,from Unix

Solution:

So here we go. a gzip compressed data. The best way to deal with it to use “unzip” command line tool. You can install it using this command:

sudo apt-get install gunzip 

Now loaded with gunzip we are ready to tackle this file. First gunzip the file to a .tar file and then untar it using tar command somewhat in following manner:

gunzip filename.tar.gz 
tar xvzf filename.tar 

Hope the post has helped you. Feedback, suggestions are most welcome. Enjoy :)

How to extract .tar.bz2 and .tar.gz file in Linux

Tar is an archiving utility in Linux. Lets see how can we extract various archived files in Linux using this utility.  We will also see the meaning of the options provided with the commands. Type the following commands in terminal (Keyboard short cut: Ctrl+Alt+T in Ubuntu):

Extracting .tar.bz2:

tar xvjf filename.tar.bz2 location

Extracting .tar.gz:

tar xvzf filename.tar.gz location

Where:

x — extract

v — verbose (it will show the extracting files in the terminal)

f — file

z — gzip (or gz in short)

j — bzip2 (or bz2 in short)

location — location where you want to save the extracted the files. If you want to save it in the same directory where you have the zipped file use “.” in place of “location”.

All extracted files will be kept in a single directory automatically. The name of this directory is decided by the zipped file itself.

Hope the post has helped you. Feedback, suggestions are most welcome. Enjoy :)