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.
tar -xf example.tar
The -v or --verbose option can be used to display the files being extracted.
tar -xvf 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 directroy. In this example, both of these commands have the same result, where the contents of example.tar are extracted to the / directory.
tar -xf example.tar -C / cd /; tar -cf example.tar
The -z option will be needed if the archive is gzip compressed.
tar -zxf example.tar.gz
The -j option will be needed if the archive is bz2 compressed.
tar -jxf example.tar.bz2
To extract a single file in the archive, include the path to the file in the archive.
tar -xf example.tar path/to/example.txt