CompTIA Linux+ Exam XK0-004: Packaging and Compressing Files | YourSiteName

Packaging and Compressing Files in Linux: XK0-004 Exam Answer

Question

A systems administrator must clean up all application files in the directory /var/log/app.

However, the company's security policy requires the files to be kept on the backup server for one year.

The Linux server has only the tar and bzip2 packages installed.

Which of the following commands will package and compress the files?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B.

The correct answer is B. tar "jcvf applicationfiles.tar.bz2 /var/log/app/*

Explanation: The tar command is used to create an archive, also known as a tarball, of one or more files and directories. The tarball can then be compressed using various compression algorithms. In this case, we need to package and compress the files in the /var/log/app directory into a single file.

The options used in the command are:

  • j: use bzip2 compression
  • c: create a new archive
  • v: verbosely list the files being processed
  • f: use the following filename

Therefore, the correct command to package and compress the files in the /var/log/app directory using bzip2 compression is:

css
tar "jcvf applicationfiles.tar.bz2 /var/log/app/*

Option A (tar "zcvf applicationfiles.tar.bz2 /var/log/app/*) uses gzip compression (z option) instead of bzip2, which is not specified in the question. So this is not the correct answer.

Option C (tar "cvf applicationfiles.tar.bz2 /var/log/app/*) only creates an archive without compressing it. So this is not the correct answer.

Option D (tar "xvf applicationfiles.tar.bz2 /var/log/app/*) is used to extract the files from an archive, not create one. So this is not the correct answer.