I assume most of us are familiar with creating tar, tar.gz and tar.bz2 files. But do you know how to learn what is inside that tar file without extracting it? If your answer is "No" then you have come to the right place.
The following commands can be used to list the contents of a tar, tar.gz, tar.bz2 files. These commands becomes handy when you have multiple tar files and if you are searching for a particular file or folder.
To list the contents of a tar file :
tar -tvf filename.tar
To list the contents of a tar.gz file :
tar -tvf filename.tar.gz
To list the contents of a tar.bz2 file :
tar -tvf filename.tar.bz2
Each of these commands will list the contents of tar, tar.gz, tar.bz2 files. Hope this helps.