Commands.page Logo

How to List Files Inside a tar.bz2 Archive in Ubuntu

This guide explains how to view the contents of a compressed tar.bz2 archive without extracting it on Ubuntu. You will learn the specific tar command flags required to list files safely and efficiently directly from the terminal.

To list the files inside a .tar.bz2 archive, use the tar command with the list, bzip2, and file flags. This process allows you to inspect the archive contents before deciding whether to extract them.

The primary command is:

tar -tjf archive_name.tar.bz2

Breakdown of the flags used: * -t: Lists the contents of the archive. * -j: Filters the archive through bzip2 compression. * -f: Specifies the filename to operate on.

Replace archive_name.tar.bz2 with the path to your specific file. For a more detailed list that includes permissions, sizes, and dates, add the verbose flag -v:

tar -tvjf archive_name.tar.bz2

This command is built into the standard Ubuntu installation and requires no additional packages.