Courseiva
Essential Commands →easyMultiple Choice

LFCS Essential Commands Practice Question

A user needs to view the contents of a compressed log file /var/log/syslog.gz without first decompressing it. Which command should they use?

⚠ Common exam trap

Test-takers frequently confuse commands that permanently decompress files (like `gzip -d` or `gunzip`) with commands that only display the contents, leading them to choose an option that alters the file system state instead of just viewing the data.

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 /var/log/syslog.gz

`zcat` is specifically designed to read the contents of gzip-compressed files without permanently decompressing them. It decompresses the data on the fly and sends the output to stdout, allowing the user to view the log file's contents directly from the terminal.

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 /var/log/syslog.gz

    Why this is correct

    `zcat` decompresses gzip data to standard output, so the file's contents appear on screen without altering the original `.gz` file on disk. This satisfies the stem's constraint of viewing without prior decompression, unlike `gunzip`, which removes the archive, or `cat`, which would emit raw compressed bytes.

  • ✗

    gzip -d /var/log/syslog.gz

    Why it's wrong here

    gzip -d decompresses the file in place, replacing syslog.gz with an uncompressed syslog and writing to disk, which the scenario forbids. It is the right command when permanent extraction is wanted, whereas viewing without extraction needs zcat or gzip -dc piped to a pager.

  • ✗

    gunzip /var/log/syslog.gz

    Why it's wrong here

    gunzip extracts the archive to disk and removes the .gz file, altering the filesystem rather than displaying contents. It is correct when the goal is permanent decompression, but the scenario requires reading the log in place, which zcat or gzip -dc achieves.

  • ✗

    cat /var/log/syslog.gz

    Why it's wrong here

    cat streams the raw gzip binary, printing compressed bytes rather than readable log text. It is correct for uncompressed files, but gzip data must be decompressed on the fly, which zcat or gzip -dc does while leaving syslog.gz intact on disk.

About these practice questions

Courseiva writes every LFCS question from scratch — 406 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 →

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.