Unzipping a .gz file
gunzip filename.tar.gz
This replaces filename.tar.gz with filename.tar
Extracting tar files
tar xvf filename.tar
Note: Always move to an empty directory before unpacking a tarfile. When you unpack a tarfile its contents are written to the current directory. Any file or directory with the same name as the contents of the tarfile will be overwritten!
A quick method
Alternatively, you can unpack a compressed/zipped tarfile using the zcat or gzcat command. (gzcat is a local alias for the GNU zcat command). This leaves the compressed .Z or .gz tarfile intact. For example:
zcat filename.tar.Z | tar xvf -
or
gzcat filename.tar.gz | tar xvf -
The zcat command recreates the uncompressed tarfile, which is then piped into the tar command to extract the files.