Courseiva
Essential Commands →easyMultiple Choice

LFCS Essential Commands Practice Question

A user needs to see the contents of a gzip-compressed file 'data.txt.gz' without decompressing it. Which command is appropriate?

⚠ Common exam trap

A common mix-up: candidates confuse `zcat` with `gunzip` or assume `gzcat` is the correct command, but the LFCS exam expects knowledge of the standard `zcat` utility for viewing compressed files without 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

✓

zcat data.txt.gz

The `zcat` command reads a gzip-compressed file and outputs its decompressed content to stdout without modifying the original file. This allows the user to view the contents of 'data.txt.gz' without permanently decompressing it.

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 data.txt.gz

    Why it's wrong here

    gunzip decompresses the archive on disk, replacing data.txt.gz with an uncompressed data.txt, so the file is no longer compressed and the original is lost. It is tempting because gunzip is the standard tool for restoring gzipped files, and would be correct when the user genuinely wants a permanent decompressed copy.

  • ✓

    zcat data.txt.gz

    Why this is correct

    zcat streams the decompressed contents of data.txt.gz directly to standard output, leaving the original compressed file untouched on disk. This satisfies the stem's constraint of viewing the file without decompressing it, since no .gz-to-plain extraction occurs. gzip's own -c flag could also write to stdout, but zcat is the purpose-built tool.

  • ✗

    ./data.txt.gz

    Why it's wrong here

    Executing the file directly attempts to run it as a program, which fails because a gzip archive is not executable code. It is tempting because scripts are run this way, and it would be correct had 'data.txt.gz' been a shell script with execute permission rather than compressed data.

  • ✗

    gzcat data.txt.gz

    Why it's wrong here

    `gzcat` is a legacy alias for `zcat` on some BSD systems, but it is not guaranteed to exist on Linux distributions covered by LFCS, where GNU gzip provides `zcat` and `zless` instead. It is tempting because it genuinely streams decompressed output to stdout, which is exactly the behaviour required here — just under a different command name.

About these practice questions

This LFCS question is part of Courseiva's 406-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.