Courseiva
Essential Tools →easyMultiple Select

EX200 Essential Tools Practice Question

Which two commands can be used to display the contents of a compressed .tar.gz archive without extracting it? (Choose two)

⚠ Common exam trap

Red Hat often tests the distinction between `-t` (list) and `-x` (extract), and candidates mistakenly choose `tar -xf` thinking it only displays contents, or they confuse `gzcat` with a listing tool.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

tar -tzf archive.tar.gz

`tar -tzf` lists the contents of a gzip-compressed tar archive without extracting it. The `-t` flag tells tar to list the table of contents, `-z` handles the gzip decompression on the fly, and `-f` specifies the archive file. This is the standard way to inspect a .tar.gz file's contents without extraction.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    gzcat archive.tar.gz

    Why it's wrong here

    gzcat archive.tar.gz is wrong because it only performs gzip decompression, sending the raw uncompressed tar byte stream to standard output. It does not interpret the tar container format, so instead of a clean file listing you see binary tar headers and file contents interleaved with padding. To actually view the archive's member names, the decompressed output would need to be piped into a command such as tar -t.

  • ✗

    less archive.tar.gz

    Why it's wrong here

    less is a text pager, not an archive browser; it reads the file as a byte stream and has no built-in logic to parse a tar archive or understand gzip compression. On a standard RHEL system without a configured lesspipe preprocessor, it displays compressed binary data as escaped characters and garbage rather than a directory listing. Even if a decompression filter were active, less would only show the raw tar stream, not the concise member list that tar -t produces.

  • ✓

    tar -tzf archive.tar.gz

    Why this is correct

    tar -tzf archive.tar.gz is the textbook explicit way to list a gzipped tarball's contents. The -z option tells tar to decompress the archive through gzip before reading it, -t selects list mode instead of extract mode, and -f names the archive file. The output is a path-by-path listing of every file and directory stored in the archive, with no data extracted to disk.

  • ✓

    tar -tf archive.tar.gz

    Why this is correct

    tar -tf archive.tar.gz is also correct because GNU tar and modern tar implementations automatically detect gzip compression from the archive's magic bytes, so -z is redundant. In list mode, -t, tar merely reads the tar headers after transparently decompressing the stream and prints the member names. This is the more portable, modern form, while -tzf remains useful for older tar versions that require explicit compression flags.

  • ✗

    tar -xf archive.tar.gz

    Why it's wrong here

    tar -xf archive.tar.gz is incorrect for this question because -x switches tar into extract mode, restoring files and directories from the archive into the filesystem, possibly overwriting existing files. It never prints a listing of contents before extraction. To inspect what is inside the archive you need -t (list), not -x.

About these practice questions

Courseiva writes every EX200 question from scratch — 427 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This EX200 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX200 exam.