List files inside a tar archive without unpacking

Peek into a .tar.gz to check what's inside before extracting hundreds of files.

LinuxarchivetarLow risk
Run tar -tzf archive.tar.gz to list its contents, or tar -tzf archive.tar.gz path/ to check for one folder.

01Command

Command
$ tar -tzf backup.tar.gz | less && tar -tf archive.tar | head -50

02What it does

The -t switch makes tar read the archive and print filenames only — nothing is written to disk. Add -z for gzip archives (.tar.gz), -j for bzip2 (.tar.bz2), or plain -tf for uncompressed .tar. Pipe through grep or less to search big archives, e.g. tar -tzf backup.tar.gz | grep '\.conf$'.

03Risk

RiskLow risk
!Warning: On compressed archives, listing still requires reading (and decompressing) the whole file, so huge archives take a while. Listing does not extract anything, so it's safe on read-only media.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • tar(1) — Linux manual page
    man7.org · community · 2026-09-17
    Evidence: tar -t lists archive contents without extracting; -z handles gzip compression and -f names the archive file.

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions