nerdexam
LPI

010-160 · Question #52

Which of the following commands will create an archive file, named backup.tar, containing all the files from the directory /home?

The correct answer is E. tar -cf backup.tar /home. The tar command requires -c to create an archive and -f to name the output file, with the filename immediately following -f and the source path listed last.

The Power of the Command Line

Question

Which of the following commands will create an archive file, named backup.tar, containing all the files from the directory /home?

Options

  • Atar /home backup.tar
  • Btar -cf /home backup.tar
  • Ctar -xf /home backup.tar
  • Dtar -cf backup.tar /home
  • Etar -cf backup.tar /home

How the community answered

(17 responses)
  • D
    6% (1)
  • E
    94% (16)

Why each option

The tar command requires -c to create an archive and -f to name the output file, with the filename immediately following -f and the source path listed last.

Atar /home backup.tar

This invocation omits the required -c and -f flags, making it an invalid tar command that will not produce a named archive.

Btar -cf /home backup.tar

The filename and source path are swapped - /home appears where the archive name should be, causing tar to misinterpret the arguments.

Ctar -xf /home backup.tar

The -x flag instructs tar to extract an existing archive, not create one, which is the opposite of the intended operation.

Dtar -cf backup.tar /home

Choice D is textually identical to the correct answer E (`tar -cf backup.tar /home`) and represents valid syntax - this appears to be a duplicate option in the question.

Etar -cf backup.tar /homeCorrect

The syntax `tar -cf backup.tar /home` correctly uses -c (create) and -f (specify filename), with backup.tar placed immediately after -f as required by tar's argument parsing. The source directory /home appears last, telling tar which content to include in the archive. Note that choice D is textually identical to E - both represent the correct syntax, which appears to be a duplication error in the question.

Concept tested: tar command syntax for creating file archives

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

Topics

#tar command#archive creation#backup#command syntax

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice