LFCS Essential Commands Practice Question
A user wants to view the contents of a compressed file file.txt.gz without decompressing it permanently. Which two commands can be used? (Choose two.)
⚠ Common exam trap
A common mix-up: candidates confuse `gzip -d` (which permanently decompresses) with `gunzip -c` (which outputs to stdout), or mistakenly think `gzip -l` shows file contents instead of metadata.
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
✓
gunzip -c file.txt.gz
`gunzip -c` decompresses the file to standard output, allowing the user to view the contents without modifying the original compressed file. Option B is correct because `zcat` is equivalent to `gunzip -c` and reads the compressed file directly, outputting the decompressed data to the terminal without permanent decompression.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
gunzip -c file.txt.gz
Why this is correct
Outputs decompressed content to stdout, leaving the .gz file untouched.
- ✓
zcat file.txt.gz
Why this is correct
Outputs decompressed content to stdout without saving.
- ✗
gzip -l file.txt.gz
Why it's wrong here
Lists compression information, not the contents.
- ✗
gzip -d file.txt.gz
Why it's wrong here
Decompresses and creates file.txt, removing the .gz file.
- ✗
gzip -k file.txt.gz
Why it's wrong here
Compresses, not decompresses.
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.