Ubuntu – How to view the contents of tar.gz file without extracting from the command-line

command line

I want to see the contents (list of files and folders) of an archive, for example a tar.gz file without extracting it.

Are there any methods for doing that?

Best Answer

  • Run the below command in the terminal to see the contents of a tar.gz file without extracting it:

    tar -tf filename.tar.gz
    

    screenshot of listing compressed tarball files in the terminal

    -t, --list
    List the contents of an archive. Arguments are optional. When given, they specify the names of the members to list.

    -f, --file=ARCHIVE Use archive file or device ARCHIVE...