You cannot "install" a .tar.gz
file or .tar.bz2 file. .tar.gz
files are gzip-compressed tarballs, compressed archives like .zip
files. .bz2 files are compressed with bzip2. You can extract .tar.gz
files using:
tar xzf file.tar.gz
Similarly you can extract .tar.bz2 files with
tar xjf file.tar.bz2
If you would like to see the files being extracted during unpacking, add v
:
tar xzvf file.tar.gz
Even if you have no Internet connection, you can still use Ubuntu's package management system, just download the .deb
files from http://packages.ubuntu.com/. Do not forget to download dependencies too.
For an easier way to install packages offline, see the question How can I install software offline?.