LPIC-1 GNU and Unix Commands Practice Question
Which TWO commands can be used to display the contents of a compressed file without decompressing it to disk? (Choose two.)
⚠ Common exam trap
It's easy for candidates to confuse commands that decompress to stdout (like `zcat` and `bzcat`) with commands that decompress to disk (like `gzip -d` or `uncompress`), or they mistakenly think `tar -xzf` only displays the archive contents when it actually extracts them.
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 file.gz
Option A, zcat file.gz, is correct because zcat (equivalent to gzip -dc) decompresses the gzip stream and writes the contents to standard output, so the file is displayed on screen without ever being written back to disk. Option D, bzcat file.bz2, is correct for the same reason with bzip2-compressed files: it decompresses to stdout, letting you view the contents without creating a decompressed file on disk. Option B, gzip -d file.gz, is wrong because the -d flag decompresses the file on disk, replacing file.gz with the uncompressed file rather than displaying it. Option C, tar -xzf file.tar.gz, is wrong because -x extracts the archive's members to the filesystem, writing files to disk instead of showing them. Option E, uncompress file.Z, is wrong because it restores the original uncompressed file on disk and removes the .Z file, not displaying contents to stdout.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
zcat file.gz
Why this is correct
zcat streams the decompressed output of a gzip file straight to standard output, leaving the original file.gz untouched on disk. This directly satisfies the stem's constraint of viewing contents without decompressing to disk, since no extracted file is ever written.
- ✗
gzip -d file.gz
Why it's wrong here
gzip -d decompresses file.gz to disk, deleting the compressed original, so nothing is displayed without writing to storage. It tempts because gzip is the standard GNU compression utility, and would be correct where the task is restoring a compressed file for further processing rather than viewing its contents in place.
- ✗
tar -xzf file.tar.gz
Why it's wrong here
tar -xzf extracts the archive to disk, writing every member to the filesystem, which is precisely what the question excludes. It tempts because tar handles compressed archives natively and is the standard tool for listing contents, but listing requires -t (tar -tzf), not extraction with -x.
- ✓
bzcat file.bz2
Why this is correct
bzcat streams the decompressed contents of a bzip2 archive straight to standard output, leaving the original file.bz2 untouched on disk. This satisfies the stem's constraint of viewing contents without extracting to disk, unlike bunzip2, which removes the compressed file and writes a decompressed copy.
- ✗
uncompress file.Z
Why it's wrong here
uncompress file.Z restores the file to disk, replacing the compressed original, so contents are not displayed without writing to storage. It tempts because it is the canonical tool for .Z archives, and would be correct where the task is decompressing a file for subsequent use rather than viewing it in place.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LPIC-1 question from scratch — 402 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 →
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.