nerdexam
Linux_Foundation

LFCS · Question #801

Which of the following commands displays the contents of a gzip compressed tar archive?

The correct answer is B. tar ztf archive.tgz. To display the contents of a gzip compressed tar archive, use the tar command with the z (gzip), t (list), and f (file) options.

Submitted by akirajp· Apr 18, 2026Essential Commands

Question

Which of the following commands displays the contents of a gzip compressed tar archive?

Options

  • Agzip archive.tgz | tar xvf -
  • Btar ztf archive.tgz
  • Cgzip -d archive.tgz | tar tvf -
  • Dtar cf archive.tgz

How the community answered

(37 responses)
  • B
    92% (34)
  • C
    5% (2)
  • D
    3% (1)

Why each option

To display the contents of a gzip compressed tar archive, use the `tar` command with the `z` (gzip), `t` (list), and `f` (file) options.

Agzip archive.tgz | tar xvf -

`gzip archive.tgz` would attempt to re-compress an already compressed file or incorrectly handle the pipe, and `xvf -` would extract, not just list, if it even received input.

Btar ztf archive.tgzCorrect

The command `tar ztf archive.tgz` efficiently displays the table of contents (`t`) of a specified archive file (`f`) that has been compressed with gzip (`z`), without extracting its contents.

Cgzip -d archive.tgz | tar tvf -

`gzip -d archive.tgz` without `-c` decompresses to a file named `archive.tar` (or similar) in the current directory and does not send output to stdout for piping; therefore, this command sequence is functionally incorrect for piping.

Dtar cf archive.tgz

`tar cf archive.tgz` is used to create (`c`) a tar archive (`f`) from files, not to display the contents of an existing one.

Concept tested: tar command (gzip, list contents)

Source: https://www.gnu.org/software/tar/manual/tar.html

Topics

#tar#gzip#Archiving#File Management

Community Discussion

No community discussion yet for this question.

Full LFCS Practice