Courseiva
Essential Tools →mediumMultiple Select

EX200 Essential Tools Practice Question

Which TWO commands can be used to view the contents of a compressed file named 'archive.tar.gz' without extracting it?

⚠ Common exam trap

Many candidates confuse decompression commands (like `gunzip -c`) with listing commands, or they assume `tar -xf` can list contents because of the `-x` (extract) flag, but `-x` always writes files unless combined with `-t` which overrides it to list mode.

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 archive.tar.gz` lists the contents of a gzip-compressed tar archive without extracting it. The `-t` option tells tar to list the table of contents, `-z` filters the archive through gzip decompression, and `-f` specifies the archive file. This command reads the archive metadata directly without writing any files to disk.

Answer analysis

Option-by-option breakdown

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

  • ✗

    gzip -d archive.tar.gz

    Why it's wrong here

    Running gzip -d archive.tar.gz strips off the gzip compression layer and writes an uncompressed archive.tar file to disk, but it never examines the tar container itself. This command only reverses the compression; it does not parse the tar header records, so no listing of archive members is produced. To actually view the contents, you would still need to run tar -t on the resulting .tar file.

  • ✓

    tar -tzf archive.tar.gz

    Why this is correct

    tar -tzf archive.tar.gz is the canonical one-step listing command: -t selects list mode, -z tells tar to transparently decompress the gzip layer, and -f specifies the archive filename. It reads the gzip-compressed tar stream, walks each tar header entry, and prints metadata such as filenames, permissions, sizes, and timestamps without extracting any files. This is the standard, safe way to inspect a .tar.gz archive's contents.

  • ✗

    gunzip -c archive.tar.gz

    Why it's wrong here

    gunzip -c archive.tar.gz decompresses the gzip stream to standard output, so your terminal receives the raw tar binary payload — not a human-readable directory listing. By itself it only reverses the compression; the tar archive's structure remains unexamined. You would need to pipe that output into tar -t (for example, gunzip -c archive.tar.gz | tar -t) to actually list the files inside the archive.

  • ✗

    tar -xf archive.tar.gz

    Why it's wrong here

    tar -xf archive.tar.gz extracts the entire archive into the current working directory: -x switches tar to extraction mode and -f names the archive. Unlike listing, this command creates or overwrites real files on disk, which can be destructive if you only intended to inspect the contents. Listing requires the -t flag instead of -x, so this command does not show what is inside the archive.

  • ✓

    zcat archive.tar.gz | tar -t

    Why this is correct

    zcat archive.tar.gz | tar -t is a two-stage pipeline that achieves the same result as tar -tzf: zcat decompresses the gzip layer to stdout, and tar -t reads that raw tar stream from stdin and prints its contents. This approach explicitly demonstrates that a .tar.gz file is a tar archive wrapped in gzip compression, and it is especially useful if your tar binary lacks built-in gzip support. It lists archive members without extracting them to disk.

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.