[how-to] Listing contents of archive without opening it


Active Member
I found a way to list the contents of an archive without actually opening it in archive manager. These commands are particularly useful if the archive is huge (10 GB or more) and it takes a long time for the manager to read it. With these commands you should be able to check if the archive is broken - theoretically, at least. If it's broken, the command should return quite a different output.

For all tarballs:
tar -tvf archive.tar
tar -ztvf archive.tar.gz
tar -jtvf archive.tar.bz2
tar -Jtvf archive.tar.xz
For 7z, zip, rar, iso, exe, etc. - doesn't support tarballs!!!
7z l file.7z
7z l file.zip
7z l file.rar
7z l file.iso
7z l file.exe
Note: the symbol after 7z is small letter "L", it's not the vertical " | " separation symbol. Stands for "list".

The usage is simple. Using your favorite file manager manually navigate to the directory where the archive is. Open a terminal in its folder (some file managers can do that by pressing F4 inside the folder) and type the corresponding command from the above by replacing the word "file" with your archive name. I'm not sure if these commands support spaces, so you better rename the archive and replace all spaces with dashes or whatever you like.

Here's an example of how to use the commands:
[[email protected]]: /media/1000GB/123>$ 7z l linux-vbox.zip

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=bg_BG.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i3-4170 CPU @ 3.70GHz (306C3),ASM,AES-NI)

Scanning the drive for archives:
1 file, 34260 bytes (34 KiB)

Listing archive: linux-vbox.zip

Path = linux-vbox.zip
Type = zip
Physical Size = 34260

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2019-06-25 19:22:46 D....            0            0  LINUX
2019-06-25 19:22:46 .....         2644         1159  LINUX/LINUX.vbox
2019-06-25 19:22:45 .....         2568         1136  LINUX/LINUX.vbox-prev
2019-06-25 19:22:42 .....       141312          392  LINUX/LINUX.vhd
2019-06-25 18:51:08 D....            0            0  LINUX/Logs
2019-06-25 19:22:46 .....       153243        30703  LINUX/Logs/VBox.log
------------------- ----- ------------ ------------  ------------------------
2019-06-25 19:22:46             299767        33390  4 files, 2 folders
[[email protected]]: /media/1000GB/123>$

Members online

Latest posts