How to view Contents of Compressed files in Linux

We generally use archives and/or compression tools in Linux to save disk space. Mostly, we use it to backup files or folders.

Linux has several applications that compress and decompress files. But we only use some of them and here are the best Compression and Archive tools for Linux.

Compressed files can be kept as long as needed, but we might forget the archived contents after sometimes. For some reason, if you want to see which content/file was archived without extracting.

Yes, this can be done using the zcat, zless, zmore, tar and bzcat commands. Moreover these commands must be used based on the compressed file extension.

In this tutorial, we’ll show you how to view the contents of compressed and/or archived files & folders without extracting it in Linux. Also, we will show you, how to view the list of files/directories in it.

1) Viewing contents of an archived/compressed files without extracting in Linux

There are several commands in Linux that allows you to view the contents of the compressed file without extracting them using zcat, zless, and zmore commands.

1.1) Viewing contents of ZIP & GZIP file in Linux

You can use any of the below commands to view the contents of a zip file.

zcat 2Gtest.gz
zmore 2Gtest.gz
zless 2Gtest.gz

This is a test archive file and named linuxgeek.txt
Thanks for visiting our website "" !!

Make a note: If the 'zip' file contains more than one file, these commands will not display the entire contents, but with ‘gz’ file there will be no problem.

This is a test archive file and named linuxgeek.txt
Thanks for visiting our website "" !!
gzip: has more than one entry--rest ignored

To overcome the above issue use unzip command with '-c' option as shown below.

unzip -c
unzip command to view the contents of file in Linux

1.2) Viewing contents of bzip2/bz2 file in Linux

You can use any of the below commands to view the contents of a bzip2 or bz2 file.

bzcat 2Gtest_1.bz2
bzmore 2Gtest_1.bz2
bzless 2Gtest_1.bz2

1.3) Viewing contents of XZ file in Linux

You can use less command to view the contents of a xz file.

less 2Gtest_1.xz

2) Checking list of files/directories from archived/compressed file without extracting in Linux

In the above section, we have shown you how to view the contents of various compressed format files in Linux. Now, let’s show you how to view a list of files and directories from a compressed file without extracting it in Linux.

2.1) Checking list of files from ZIP file

You can use few command to view list of files from zip file as shown below:

Using zininfo command: This shows some useful information as well such compressed file size, actual file size, number of files associated, file permissions and compressed ratio percentage.


Zip file size: 515 bytes, number of entries: 2
-rw-rw-r--  3.0 unx      102 tx defN 23-Jun-28 16:55 linuxgeek.txt
-rw-rw-r--  3.0 unx      106 tx defN 23-Jun-28 16:55 fosstechi.txt
2 files, 208 bytes uncompressed, 185 bytes compressed:  11.1%

Using zip command with the -sf option.

zip -sf

Archive contains:
Total 2 entries (208 bytes)

Using unzip command with -l option.

unzip -l

  Length      Date    Time    Name
---------  ---------- -----   ----
      102  2023-06-28 16:55   linuxgeek.txt
      106  2023-06-28 16:55   fosstechi.txt
---------                     -------
      208                     2 files

2.2) Checking list of files from 7z file

You can view the list of files from a 7z file using the 7z command with the help of the 'l' option.

7z l 2Gtest_1.7z

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_IN,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (506E3),ASM,AES-NI)

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

Listing archive: 2Gtest_1.7z

Path = 2Gtest_1.7z
Type = 7z
Physical Size = 308
Headers Size = 184
Method = LZMA2:12
Solid = +
Blocks = 1

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2023-06-28 16:55:20 ....A          106          124  fosstechi.txt
2023-06-28 16:55:15 ....A          102               linuxgeek.txt
------------------- ----- ------------ ------------  ------------------------
2023-06-28 16:55:20                208          124  2 files

2.3) Checking list of files from tar file

You can check the contents of the tar archive by using the tar command with option 't'.

tar -tvf 2Gtest.tar
tar -tvf 2Gtest.tar.gz
tar -tvf 2Gtest.tar.bz2

drwxrwxr-x linuxgeek/linuxgeek 0 2023-06-28 20:13 2g-docs/
-rw-rw-r-- linuxgeek/linuxgeek 511 2023-06-03 18:50 2g-docs/asm_disk_mapping.txt
-rw-rw-r-- linuxgeek/linuxgeek 1104 2023-06-25 20:37 2g-docs/veritas_installation.txt
-rw-rw-r-- linuxgeek/linuxgeek 1777 2023-06-17 18:28 2g-docs/kernel-info.txt
-rw-rw-r-- linuxgeek/linuxgeek  160 2023-06-28 19:57 2g-docs/2Gtest.xz
-rw-rw-r-- linuxgeek/linuxgeek  268 2023-06-28 16:57 2g-docs/
-rw-rw-r-- linuxgeek/linuxgeek  491 2023-06-25 21:58 2g-docs/vcs_hastatus.txt
-rw-rw-r-- linuxgeek/linuxgeek  308 2023-06-28 20:13 2g-docs/2Gtest_1.7z
-rw-rw-r-- linuxgeek/linuxgeek  332 2023-06-03 18:37 2g-docs/lun_disk_fs_map.txt
-rw-rw-r-- linuxgeek/linuxgeek  106 2023-06-28 16:55 2g-docs/fosstechi.txt
-rw-rw-r-- linuxgeek/linuxgeek  129 2023-06-28 17:35 2g-docs/2Gtest.bz2
-rw-rw-r-- linuxgeek/linuxgeek 1426 2023-06-13 22:45 2g-docs/
-rw-rw-r-- linuxgeek/linuxgeek 1289 2023-06-13 22:13 2g-docs/leapp_pre_upgrade.txt
-rw-rw-r-- linuxgeek/linuxgeek  236 2023-06-28 20:12 2g-docs/2Gtest.7z
-rw-rw-r-- linuxgeek/linuxgeek  320 2023-06-28 19:58 2g-docs/2Gtest_1.xz
-rw-rw-r-- linuxgeek/linuxgeek  642 2023-06-25 20:29 2g-docs/
-rw-rw-r-- linuxgeek/linuxgeek  124 2023-06-28 18:02 2g-docs/2Gtest.gz
-rw-rw-r-- linuxgeek/linuxgeek  249 2023-06-28 18:02 2g-docs/2Gtest_1.gz
-rw-rw-r-- linuxgeek/linuxgeek 1183 2023-06-25 20:35 2g-docs/
-rw-rw-r-- linuxgeek/linuxgeek  364 2023-06-25 21:51 2g-docs/test.txt
-rw-rw-r-- linuxgeek/linuxgeek  102 2023-06-28 16:55 2g-docs/linuxgeek.txt
-rw-rw-r-- linuxgeek/linuxgeek 1031 2023-06-27 01:23 2g-docs/veritas_license_contents.txt
-rw-rw-r-- linuxgeek/linuxgeek 1203 2023-06-13 22:59 2g-docs/
-rw-rw-r-- linuxgeek/linuxgeek  129 2023-06-28 16:55 2g-docs/linuxgeek.txt.bz2
-rw-rw-r-- linuxgeek/linuxgeek  260 2023-06-28 17:34 2g-docs/2Gtest_1.bz2
-rw-rw-r-- linuxgeek/linuxgeek  131 2023-06-28 16:55 2g-docs/fosstechi.txt.bz2
-rw-rw-r-- linuxgeek/linuxgeek  515 2023-06-28 16:57 2g-docs/

Closing Thoughts

In this tutorial, we’ve shown you how to view the contents of compressed and/or archived files & folders without extracting it in Linux. Also, we have shown you, how to view a list of files/directories in it.

If you have any questions or feedback, feel free to comment below.

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

Your email address will not be published. Required fields are marked *