Courseiva
Essential CommandsmediumMultiple SelectObjective-mapped

How to View a .gz File Without Decompressing

Which THREE of the following commands can be used to view the contents of a compressed file named 'file.gz' without permanently decompressing it? (Choose exactly three.)

Quick Answer

The correct commands are `zless`, `zmore`, and `zcat`, as all three allow you to view a compressed .gz file without permanently decompressing it. These utilities work by decompressing the file on the fly and piping the output to a pager or standard output, leaving the original `file.gz` untouched on disk. On the LFCS exam, this tests your understanding of the `z*` family of commands, which are often confused with their uncompressed counterparts—a common trap is assuming `less` or `more` can directly read gzip files, but they cannot. Remember that `zcat` sends output to the terminal (like `cat`), `zless` provides scrollable viewing (like `less`), and `zmore` pages through content (like `more`). A handy memory tip: think of the prefix "z" as "zipped," so `zcat`, `zless`, and `zmore` are simply the zipped versions of `cat`, `less`, and `more`.

⚠ Common exam trap

The trap here is that candidates mistakenly think `gunzip` or `gzip` can be used to view file contents without permanent decompression, confusing compression/decompression commands with viewing utilities like `zcat`, `zmore`, and `zless`.

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

zmore file.gz

`zmore` is a utility that allows you to view the contents of a compressed file (such as `file.gz`) page by page without permanently decompressing it. It internally decompresses the file on the fly and pipes the output through `more`, making it ideal for inspecting large compressed files without modifying the original archive.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • gzip file.gz

    Why it's wrong here

    Compresses files.

  • zmore file.gz

    Why this is correct

    Correct: displays with more.

  • gunzip file.gz

    Why it's wrong here

    Decompresses permanently.

  • zcat file.gz

    Why this is correct

    Correct: decompresses to stdout.

  • zless file.gz

    Why this is correct

    Correct: displays with less.

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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on LFCS

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. 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?

easy
  • A.zcat /var/log/syslog.gz
  • B.gzip -d /var/log/syslog.gz
  • C.gunzip /var/log/syslog.gz
  • D.cat /var/log/syslog.gz

Why A: `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.

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.