LFCS Essential Commands Practice Question
A technician needs to display the contents of a compressed file named archive.tar.gz without extracting it. Which command should be used?
⚠ Common exam trap
Watch out — candidates often confuse `tar -tf` (which works only on uncompressed tar files) with `tar -ztf` (which handles gzip), or they may mistakenly think `zcat` alone produces a readable listing, when it actually outputs raw binary tar data.
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
✓
zcat archive.tar.gz | tar -t
It uses `zcat` to decompress the `.gz` layer on the fly and pipes the resulting uncompressed tar archive into `tar -t`, which lists the contents without extracting. This allows viewing the file listing without first decompressing to disk, satisfying the requirement to display 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.
- ✗
tar -tf archive.tar
Why it's wrong here
Used for uncompressed tar files.
- ✗
tar -xzf archive.tar.gz
Why it's wrong here
Extracts files, does not just list.
- ✓
zcat archive.tar.gz | tar -t
Why this is correct
Decompresses and pipes to tar -t to list contents.
- ✗
zcat archive.tar.gz
Why it's wrong here
Only decompresses, does not list tar contents.
Go deeper
Related to this question
About these practice questions
One of 507 original LFCS practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LFCS practice question is part of Courseiva's free Linux Foundation 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 LFCS exam.