Computer Science Atlas
Step-By-Step

Ubuntu: List the Contents of a TAR File

February 17, 2021
 
Table of Contents

Step 1. Open a Terminal Session

If you're using an Ubuntu laptop or desktop, you can press Ctrl + Alt + T on your keyboard to open a new terminal window. If you're using a remote Ubuntu server, you can connect using SSH to open a new terminal session.

Step 2. Use tar -tvf

To list all the files in myfiles.tar.gz, you can run:

tar -tvf myfiles.tar.gz
$ tar -tvf myfiles.tar.gz

This command is shorthand for:

tar -t -v -f myfiles.tar.gz
$ tar -t -v -f myfiles.tar.gz

The -t option tells tar to list the contents.

The -v ("verbose") option tells tar to show file metadata info. If you omit this option, tar will only show the filenames.

And finally, -f myfiles.tar.gz tells tar which file you want to view.