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.
Question
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)- B95% (19)
- D5% (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.
--new is not a valid tar option; the correct long-form option for creating an archive is --create.
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.
--create is a valid long-form flag, but 'content' is not a recognized option and the command syntax is malformed.
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.
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
Community Discussion
No community discussion yet for this question.