LFCS Essential Commands Practice Question
Which TWO commands can be used to display the contents of a text file that has been compressed with gzip without decompressing it to disk?
⚠ Common exam trap
Many candidates confuse compression tools and their corresponding cat utilities (e.g., `xzcat` for xz, `bzcat` for bzip2, `zcat` for gzip), leading them to select a command that works on a different compression format.
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
`zcat` is a standard utility that reads gzip-compressed files and decompresses the output to stdout, allowing you to view the contents without writing a decompressed file to disk. It is functionally equivalent to `gunzip -c` and is commonly used for inspecting compressed log files or text data.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
xzcat file.gz
Why it's wrong here
Handles xz files, not gzip.
- ✗
gzip -l file.gz
Why it's wrong here
Lists compression ratios and sizes, not content.
- ✓
zcat file.gz
Why this is correct
Decompresses and prints to stdout.
- ✓
gunzip -c file.gz
Why this is correct
Decompresses to stdout, equivalent to zcat.
- ✗
bzcat file.gz
Why it's wrong here
Handles bzip2 files, not gzip.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LFCS question from scratch — 507 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 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.