This is rather a common question. The answers are as follows:-
To open a .tar file, issue the following command
tar xvf filename.tar
To open a .tar.gz file, issue the following command
tar xvfz filename.tar.gz
To open a .tgz file, issue the following command
tar xvfz filename.tgz
To open a plain .gz file, not a .tar.gz file, issue the following command
gunzip filename.gz