List files inside a tar archive without unpacking
Peek into a .tar.gz to check what's inside before extracting hundreds of files.
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 -5002What 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
!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 pageEvidence: 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