LPI
010-100 · Question #19
010-100 Question #19: Real Exam Question with Answer & Explanation
The correct answer is E. tar -cf backup.tar /home. Creating a tar archive requires the -c flag to create and -f to specify the filename, with the archive name listed before the source path.
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 -xf backup.tar /home
- Etar -cf backup.tar /home
Explanation
Creating a tar archive requires the -c flag to create and -f to specify the filename, with the archive name listed before the source path.
Common mistakes.
- A. No operation flag is given, so tar cannot determine whether to create, extract, or list, and the argument positions are also incorrect.
- B. The archive filename and source path are swapped - this would attempt to create an archive named /home containing a file called backup.tar.
- C. The -x flag signals extraction, not creation, so this would attempt to extract rather than create an archive, and the argument order is also reversed.
- D. The -x flag signals extraction, not creation, so this command would try to extract backup.tar rather than create a new archive from /home.
Concept tested. tar archive creation with -c and -f flags
Community Discussion
No community discussion yet for this question.