nerdexam
LPI

010-160 · Question #96

Which of the following commands extracts the contents of the compressed archive file1.tar.gz?

The correct answer is C. tar -xzf file1.tar.gz. Extracting a .tar.gz file requires the tar flags -x (extract), -z (gzip decompression), and -f (specify filename).

The Power of the Command Line

Question

Which of the following commands extracts the contents of the compressed archive file1.tar.gz?

Options

  • Atar -czf file1.tar.gz
  • Btar -xf file1.gz
  • Ctar -xzf file1.tar.gz
  • Dtar --extract file1.tar.gz
  • Edetar file1.tar.gz

How the community answered

(34 responses)
  • A
    3% (1)
  • C
    91% (31)
  • D
    6% (2)

Why each option

Extracting a .tar.gz file requires the tar flags -x (extract), -z (gzip decompression), and -f (specify filename).

Atar -czf file1.tar.gz

The -c flag creates a new archive rather than extracting; -czf would compress and create file1.tar.gz, the opposite of extracting it.

Btar -xf file1.gz

This command omits the -z flag needed to handle gzip decompression, and references an incorrect filename (file1.gz) that does not match the actual archive file1.tar.gz.

Ctar -xzf file1.tar.gzCorrect

The flags -x (extract), -z (filter through gzip), and -f (use the named file as the archive) together correctly decompress and unpack a .tar.gz archive. Running 'tar -xzf file1.tar.gz' fully restores all files stored in the compressed tar archive.

Dtar --extract file1.tar.gz

The --extract flag alone without -z and a proper -f filename argument cannot decompress and extract a gzip-compressed tar archive correctly.

Edetar file1.tar.gz

'detar' is not a valid Linux command and no such standard utility exists for extracting tar archives.

Concept tested: tar flags for extracting gzip-compressed archives

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

Topics

#tar command#archive extraction#gzip#command options

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice