Extract a .tar.gz file
tar xvzf file.tar.gz

xextracts.vshows the file names (verbose).zfilters the archive through gzip.fnames the archive file.
Extract to another folder
Use -C and the folder. It must exist:
tar xvzf file.tar.gz -C /path/to/somedirectory

Extract one file only
Add the name of the file as it is written in the archive:
tar -xvzf file.tar.gz test.doc

List the content first
tar -tvf file.tar.gz

Extract a .gz file
A plain .gz file is a single compressed file and not an archive:
gunzip file.gz

Extract a .tar.bz2 file
Use j in place of z:
tar xvjf file.tar.bz2

Extract .tar.xz files
Use J:
tar xvJf file.tar.xz
Modern tar can detect the compression by itself, so tar xvf file.tar.gz often works too.
Quick recap
tar xvzffor.tar.gz,tar xvjffor.tar.bz2.-C folderpicks the target.tar -tvflists what is inside.