Courseiva
GNU and Unix CommandseasyMultiple SelectObjective-mapped

LPIC-1 GNU and Unix Commands Practice Question

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

⚠ Common exam trap

It's easy for candidates to confuse `gunzip -l` (which shows compression metadata) with listing the actual file contents, or they mistakenly apply bzip2 tools to gzip archives, forgetting that each compression format requires its own specific decompression utility.

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

The `tar -tzf` command lists the contents of a tar archive compressed with gzip 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, single-command method for viewing the contents of a `.tar.gz` file 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

    gzip -d decompresses, but does not list contents; it would produce archive.tar.

  • bunzip2 -c archive.tar.gz | tar -t

    Why it's wrong here

    bunzip2 is for bzip2 compression; archive.tar.gz uses gzip.

  • tar -tzf archive.tar.gz

    Why this is correct

    Correct: tar -t lists table of contents; -z handles gzip; -f specifies file.

  • gunzip -l archive.tar.gz

    Why it's wrong here

    gunzip -l shows compression info, not the file list of the tar archive.

  • zcat archive.tar.gz | tar -t

    Why this is correct

    Correct: zcat decompresses to stdout; pipe to tar -t lists contents.

About these practice questions

This LPIC-1 question is part of Courseiva's 527-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 LPIC-1 practice question is part of Courseiva's free LPI 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 LPIC-1 exam.