nerdexam
CompTIA

XK0-004 · Question #464

A Linux administrator needs to archive all the *.log files in the /var/log directory. The directory has several symbolic link files that need to be included in the car file. Which of the following…

The correct answer is C. tar -czh logarchive.tgz /var/log/*.log. The tar command requires specific flags to handle symbolic links correctly. The -h flag (also written as --dereference) tells tar to follow symbolic links and archive the actual files they point to, rather than the links themselves. Option C uses -czh: -c creates a new archive…

System Management

Question

A Linux administrator needs to archive all the *.log files in the /var/log directory. The directory has several symbolic link files that need to be included in the car file. Which of the following commands should the administrator run to create

Options

  • Atar -tvz logarchive.tgz /var/log/".log
  • Btar -xhz Icgarchive.tgz /var/log/*.log
  • Ctar -czh logarchive.tgz /var/log/*.log
  • Dtar -cpz logarchive.tgz /var/log/*.log

How the community answered

(22 responses)
  • C
    95% (21)
  • D
    5% (1)

Explanation

The tar command requires specific flags to handle symbolic links correctly. The -h flag (also written as --dereference) tells tar to follow symbolic links and archive the actual files they point to, rather than the links themselves. Option C uses -czh: -c creates a new archive, -z compresses it with gzip (producing a .tgz), and -h dereferences symbolic links - satisfying all requirements. Option A uses -t which only lists archive contents (not create). Option B uses -x which extracts rather than creates. Option D uses -p (preserve permissions) but lacks -h, so symbolic links would be archived as links rather than their target file contents.

Topics

#tar#symbolic links#archiving#file compression

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice