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 ]
- gunzip file.tar.gz
- 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 ]
- x – extract
- v – verbose output
- j – filter the archive through bzip2
- f – read from a file
- z – filter the archive through gzip
Hope that helps.
Font: