Let's say you have a tar archive that contains the following.
tar -tf example.tar . . . tmp/sample/ tmp/sample/bar.txt tmp/sample/foo.txt
The tar command with the -x or --extract and -f or --file optiions will extract the contents of the tar archive. In this example, the contents of example.tar will be extracted into the present working directory. You will almost always want to also use the -p or --preserve-permissions flag, so that the file permissions are preserved.
tar -xpf example.tar
The -v or --verbose option can be used to display the files being extracted.
tar -xpvf example.tar . . . tmp/sample/ tmp/sample/bar.txt tmp/sample/foo.txt
As an example, if your present working directory is /home/john.doe, following will be where the archive is extracted.
/home/john.doe/tmp/sample/ /home/john.doe/tmp/sample/bar.txt /home/john.doe/tmp/sample/foo.txt
The -C or --directory options can be used to extract the contents to a specific directory. In this example, both of these commands have the same result, where the contents of example.tar are extracted to the / directory.
tar -xpf example.tar -C / cd /; tar -cf example.tar
The -z option will be needed if the archive is gzip compressed.
tar -zxpf example.tar.gz
The -j option will be needed if the archive is bz2 compressed.
tar -jxpf example.tar.bz2
To extract a single file in the archive, include the path to the file in the archive.
tar -xpf example.tar path/to/example.txt