nerdexam
LPI

010-160 · Question #17

Which of the following commands creates an archive file work.tar from the contents of the directory ./work/?

The correct answer is B. tar -cf work.tar ./work/. The tar command requires operation flags to define what action to perform. The -c flag creates a new archive and -f specifies the output filename.

The Power of the Command Line

Question

Which of the following commands creates an archive file work.tar from the contents of the directory ./work/?

Options

  • Atar --new work.tar ./work/
  • Btar -cf work.tar ./work/
  • Ctar --create work.tgz content ./work/
  • Dtar work.tar ./work/
  • Etar work > work.tar

How the community answered

(20 responses)
  • B
    95% (19)
  • D
    5% (1)

Why each option

The tar command requires operation flags to define what action to perform. The -c flag creates a new archive and -f specifies the output filename.

Atar --new work.tar ./work/

--new is not a valid tar option; the correct long-form option for creating an archive is --create.

Btar -cf work.tar ./work/Correct

The -c flag tells tar to create a new archive, and the -f flag specifies the archive filename that follows it. Together, 'tar -cf work.tar ./work/' correctly creates work.tar from the contents of ./work/. This is the standard POSIX-compliant syntax for archive creation.

Ctar --create work.tgz content ./work/

--create is a valid long-form flag, but 'content' is not a recognized option and the command syntax is malformed.

Dtar work.tar ./work/

tar requires at least one operation flag (-c, -x, -t, etc.); omitting it results in an error because tar does not know what action to perform.

Etar work > work.tar

This syntax is entirely invalid - 'work' is not a tar operation or valid filename argument in this position, and shell redirection cannot substitute for proper tar flag usage.

Concept tested: tar archive creation with -c and -f flags

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

Topics

#tar command#archive creation#tar options

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice