XK0-006 zcat Practice Question
A system administrator is working with compressed files. Which THREE commands can be used to view their contents? (Select THREE).
⚠ Common exam trap
The trap here is assuming that standard text utilities like cat and less automatically handle gzip-compressed files; the exam expects you to know the z-prefixed variants are required for transparent decompression.
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
✓
zgrep
Option A, zgrep, is correct because it searches inside gzip-compressed files directly, decompressing the stream on the fly and printing matching lines without requiring manual extraction. Option C, zcat, is correct because it decompresses gzip files to standard output, allowing their contents to be viewed (often piped to a pager). Option E, zless, is correct because it is a pager wrapper that decompresses gzip files and displays them page by page, making it ideal for viewing compressed content interactively. Options B (cat) and D (less) are not marked correct because they operate on plain uncompressed files and would output raw binary garbage when applied directly to a gzip-compressed file.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
zgrep
Why this is correct
zgrep decompresses the file in memory and searches it for a pattern, printing matching lines to standard output. This lets the administrator view relevant compressed content without extracting the archive first, satisfying the viewing requirement.
- ✗
cat
Why it's wrong here
cat reads raw bytes and prints compressed data as binary garbage, so it cannot display the decompressed contents. It is tempting because cat is the standard way to view plain text files, and piping it into a decompressor works, but cat alone does not decompress anything.
- ✓
zcat
Why this is correct
`zcat` decompresses gzip-compressed data and writes it to standard output, letting the administrator read file contents without extracting anything to disk. This directly satisfies the requirement to view compressed contents, since the stem asks which commands display them rather than decompress them into separate files.
- ✗
less
Why it's wrong here
less has no built-in decompression, so opening a gzip or bzip2 file shows unreadable binary rather than the original text. It is tempting because less is the usual pager for viewing text files, and zless exists precisely to page compressed files, but plain less cannot decompress them.
- ✓
zless
Why this is correct
zless decompresses on the fly and pipes the output through the less pager, letting the administrator scroll through a gzip-compressed file without extracting it to disk first. This satisfies the requirement to view compressed contents directly.
Go deeper
Related to this question
About these practice questions
One of 781 original XK0-006 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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CompTIA exam blueprint
This XK0-006 practice question is part of Courseiva's free CompTIA 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 XK0-006 exam.