When you extract files from a ZIP or TAR archive, the files are placed in a directory called “output”. The directory contains the files that were extracted, as well as any subdirectories. To view the contents of a ZIP or TAR file in Linux, use the ls -l command. This command prints out the list of files and directories in the output directory. For example, if you extract a ZIP file named myfile.zip from an FTP site, the ls -l command would show the following: -rw-r–r– 1 root root 9 Jul 10 07:12 myfile.zip


Working with archives is a common task in Linux, but sometimes, you may not know what the contents of the archive look like. If you want to take a peek at the inside of a ZIP or TAR file without extracting it, there are tools that can help you.

Using unzip to View ZIP Files

To view inside ZIP files, you’ll need the unzip utility, which might not be included by default. You can install it from your system’s package manager if it isn’t:

This utility is used to extract ZIP files, but with the lowercase -l flag, it will list the contents instead:

If you want just a raw list of all the files in the archive, you can use zipinfo with the -1 flag to only print filenames:

This can be useful for bash scripts, or when piped to other commands like less, which can help you search through a large archive. You can also pipe it to a text utility like grep or sed to find matches for certain files:

RELATED: How to Use the less Command on Linux

Using tar to View tarballs

TAR archives, also known as tarballs, are another kind of archive format used commonly in Linux. You can also print the contents of these without extracting them, by using the -t flag

Like zipinfo, this prints a raw list of all the files, and can be piped to other utilities for processing.