(Solved) How to Uncompress tar.gz from command line

There is more than one way to do this, however I tend to do it like this from command prompt:

Uncompress tar.gz

The below does both the uncompressing and untarring in a single command and puts the contents in the same directory you are in:

Code: [ Select ]
tar zxvf file.tar.gz

The z argument basically does the gunzip work for you.

Uncompress tar.gz into different directory

Use the -C argument to specify the path to place the files:

Code: [ Select ]
tar zxvf file.tar.gz -C /path/to/somedirectory

 

Uncompress first, untar second

When you uncompress first using gunzip, it will strip the .gz file extension from the file leaving you with a .tar file:

Code: [ Select ] [ Line Numbers Off ]
  1. gunzip file.tar.gz
  2. tar xvf file.tar

 

Uncompress tar.bz2

You might also encounter a bz2 file that you need to uncompress and untar:

Code: [ Select ]
tar xvjf file.tar.bz2

 

Common Tar Arguments

With tar some of the arguments we used above mean the following:

Code: [ Select ] [ Line Numbers Off ]
  1. x – extract
  2. v – verbose output
  3. j – filter the archive through bzip2
  4. f – read from a file
  5. z – filter the archive through gzip

Hope that helps.

Font:

How to Uncompress tar.gz from command line

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site