Sometime you may need to view the contents of files included in the tar file. In such cases, you can run the below commands according to your file format.
List the contents of a tar file
[root~]#tar -tvf filename.tar
List the contents of a tar.gz file
[root~]#tar -ztvf filename.tar.gz
List the contents of a tar.bz2 file
[root~]#tar -jtvf filename.tar.bz2
If the compressed file contains large number of files, then it is better to redirect the command output to a text file. So that you can search for any specific file or check it later.
[root~]#tar -tvf filename.tar > finename.txt