Back up and Compress Linux Folder: Command for XK0-004 Exam | CompTIA Linux+

How to Back up and Compress /usr/domain Folder: XK0-004 Exam | CompTIA Linux+

Question

A Linux administrator needs to back up the folder /usr/domain, and the output must be a gzip compressed tar.

Which of the following commands should be used?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

https://help.ubuntu.com/community/BackupYourSystem/TAR

The correct answer is C. tar "czvf domain.tar.gz /usr/domain

Here is the explanation:

The tar command is used to create or extract archives. It is often used in conjunction with compression utilities to create compressed archives.

The options used in the command are:

  • c: create a new archive
  • z: compress the archive with gzip
  • v: verbose mode, show the progress of the command
  • f: specifies the file name for the archive

Option A: tar "cv domain.tar.gz /usr/domain This command is incorrect because it does not include the f option to specify the file name for the archive. Also, the order of the arguments is incorrect. The correct order should be cvf and the file name should come after the options.

Option B: tar "cvf /usr/domain domain.tar.gz This command is incorrect because it specifies the wrong order of the arguments. The first argument should be the file name for the archive and the second argument should be the folder to be archived.

Option C: tar "czvf domain.tar.gz /usr/domain This command is correct. It creates a new archive with the file name domain.tar.gz, compresses it with gzip, and includes the folder /usr/domain in the archive.

Option D: tar "cxzv /usr/domain domain.tar.gz This command is incorrect because it uses the wrong compression option xz instead of z. Also, the order of the arguments is incorrect. The correct order should be czvf and the file name should come after the options.

Therefore, the correct command to back up the folder /usr/domain and compress it with gzip is: tar czvf domain.tar.gz /usr/domain.