Courseiva
GNU and Unix Commands →mediumMultiple Choice

LPIC-1 GNU and Unix Commands Practice Question

After receiving a compressed tarball archive.tar.gz from a colleague, you want to list its contents without extracting. Which command should you use?

⚠ Common exam trap

Many candidates confuse the `-x` (extract) flag with `-t` (list) because both are used for reading archives, but only `-t` lists without extracting; LPI often tests this by offering `-xzf` as a distractor, assuming candidates will misremember the flag for listing.

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

✓

tar -tvf archive.tar.gz

The `tar -tvf archive.tar.gz` command lists the contents of a compressed tarball without extracting it. The `-t` option tells tar to list the archive's table of contents, `-v` provides verbose output (showing file permissions, ownership, etc.), and `-f` specifies the archive file. Tar automatically detects and decompresses the gzip compression when reading the file, so no separate decompression step is needed.

Answer analysis

Option-by-option breakdown

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

  • ✗

    tar -xzf archive.tar.gz

    Why it's wrong here

    tar -xzf extracts the archive's files to disk, which the task explicitly excludes. Listing without extraction uses -t instead of -x. Extraction would be the correct choice when the contents are actually needed on the filesystem, for instance to install or inspect the files themselves.

  • ✗

    tar -cvf archive.tar.gz

    Why it's wrong here

    tar -cvf creates a new uncompressed archive and writes the named files into it, overwriting archive.tar.gz rather than reading it. Listing contents requires -t with -z for gzip. Creating an archive would be correct when bundling files for transfer, not when inspecting a received tarball.

  • ✗

    gzip -d archive.tar.gz | tar -t

    Why it's wrong here

    gzip -d decompresses the file to archive.tar on disk, and piping that filename into tar -t fails because tar reads standard input, not a path. Listing needs tar -tzf. This pipeline would be correct only if the decompressed tar data were streamed, for example gzip -dc archive.tar.gz | tar -t.

  • ✓

    tar -tvf archive.tar.gz

    Why this is correct

    The -t flag lists archive contents without extracting, -v shows verbose detail, and -f specifies the archive file. Combined as -tvf, tar reads archive.tar.gz and prints its members, satisfying the requirement to inspect without unpacking.

About these practice questions

Courseiva writes every LPIC-1 question from scratch — 402 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 LPIC-1 practice question is part of Courseiva's free LPI 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 LPIC-1 exam.