CompTIA XK0-006 (CompTIA Linux+) Practice Test 15

Question 140

A single large log should be compressed using gzip while retaining the original for comparison. Which command is correct?

  1. bzip2 -dc report.bz2
  2. zgrep 'ERROR' access.log.gz
  3. gzip -k access.log
  4. xz

Explanation

Correct Answer

C:

gzip compresses a file and -k keeps the source rather than deleting it. The result is normally stored with a .gz suffix.

Incorrect Answers

A:

bzip2 can decompress to stdout with -dc rather than writing a recovered file; the requirement is preserving a source file while gzip-compressing it, outside the effect of this choice.

B:

zgrep decompresses gzip data for pattern matching and reports matching records; it does not deliver preserving a source file while gzip-compressing it, which is decisive in this scenario.

D:

xz uses the LZMA2 compression format and often provides high compression ratios; the task involves preserving a source file while gzip-compressing it, whereas this addresses another subsystem.

Question 141

Two directories must be synchronized across SSH with permissions and timestamps preserved. Which command is appropriate?

  1. dd if=/dev/sdb of=disk.img bs=4M status=progress
  2. ddrescue with a mapfile
  3. rsync -a -e ssh src/ host:/backup/
  4. rsync --delete
  5. zless access.log.gz

Explanation

Correct Answer

C:

rsync -a preserves many file attributes and can transfer only changed data over SSH. A trailing slash on the source changes destination path structure.

Incorrect Answers

A:

dd copies raw blocks from an input device to an output file without interpreting the filesystem; that is not equivalent to copying changed file trees with preserved metadata over SSH.

B:

GNU ddrescue tracks which disk sectors were copied or failed in a mapfile; the administrator instead needs copying changed file trees with preserved metadata over SSH; this option serves a different purpose.

D:

The --delete option removes destination-side files absent from the source within the synchronized scope; that changes a different part of the system; the requested outcome is copying changed file trees with preserved metadata over SSH.

E:

zless presents decompressed gzip text through a pager; this does not achieve copying changed file trees with preserved metadata over SSH on the system described.

Question 142

A directory tree must be packed into an uncompressed tar archive while preserving relative paths. Which command fits?

  1. cpio -o --null
  2. tar -tf backup.tar
  3. tar -cf backup.tar project/
  4. tar -czf site.tar.gz site/

Explanation

Correct Answer

C:

tar -c creates an archive and -f selects the output filename. Compression must be requested separately if a smaller archive is required.

Incorrect Answers

A:

cpio can create an archive from pathnames on stdin, and --null supports null-terminated names; it will not provide creating an uncompressed archive of a directory under these conditions.

B:

tar -t lists member names without writing archived files to disk; using it would leave creating an uncompressed archive of a directory unresolved.

D:

tar -z filters archive content through gzip during creation; it does not deliver creating an uncompressed archive of a directory, which is decisive in this scenario.

Question 143

An administrator wants to inspect compressed log text with grep without unpacking it to a separate file. Which utility fits?

  1. tar -cf backup.tar project/
  2. zgrep 'ERROR' access.log.gz
  3. bzip2 -dc report.bz2
  4. xz
  5. rsync --delete
  6. gzip -k access.log

Explanation

Correct Answer

B:

zgrep decompresses gzip data for pattern matching and reports matching records. It does not change the compressed original.

Incorrect Answers

A:

tar -c creates an archive and -f selects the output filename; the task involves searching inside a gzip log, whereas this addresses another subsystem.

C:

bzip2 can decompress to stdout with -dc rather than writing a recovered file; that is not equivalent to searching inside a gzip log.

D:

xz uses the LZMA2 compression format and often provides high compression ratios; the administrator instead needs searching inside a gzip log; this option serves a different purpose.

E:

The --delete option removes destination-side files absent from the source within the synchronized scope; it answers a neighboring question rather than searching inside a gzip log.

F:

gzip compresses a file and -k keeps the source rather than deleting it; that changes a different part of the system; the requested outcome is searching inside a gzip log.

Question 144

An administrator needs to restore only etc/hosts from a tar archive, not all files. Which approach is appropriate?

  1. cpio -o --null
  2. tar -xf backup.tar -C /restore
  3. tar -czf site.tar.gz site/
  4. tar -xf backup.tar etc/hosts

Explanation

Correct Answer

D:

Supplying a member name after the archive selects that specific entry for extraction. This avoids overwriting unrelated files from the archive.

Incorrect Answers

A:

cpio can create an archive from pathnames on stdin, and --null supports null-terminated names; that changes a different part of the system; the requested outcome is extracting one named member from a tar file.

B:

The -C option changes the extraction target before processing members; this does not achieve extracting one named member from a tar file on the system described.

C:

tar -z filters archive content through gzip during creation; it will not provide extracting one named member from a tar file under these conditions.

Question 145

A failing drive has unreadable sectors; copying it should resume efficiently and record failed regions. Which tool is more suitable than ordinary dd?

  1. ddrescue with a mapfile
  2. rsync -a -e ssh src/ host:/backup/
  3. dd if=/dev/sdb of=disk.img bs=4M status=progress
  4. rsync --delete

Explanation

Correct Answer

A:

GNU ddrescue tracks which disk sectors were copied or failed in a mapfile. It can retry or resume a recovery operation without rereading good areas unnecessarily.

Incorrect Answers

B:

rsync -a preserves many file attributes and can transfer only changed data over SSH; the evidence calls for recovering a failing device with resumable sector tracking, not merely this separate operation.

C:

dd copies raw blocks from an input device to an output file without interpreting the filesystem; the task involves recovering a failing device with resumable sector tracking, whereas this addresses another subsystem.

D:

The --delete option removes destination-side files absent from the source within the synchronized scope; its scope differs from recovering a failing device with resumable sector tracking, so it cannot meet the stated requirement.

Question 146

A backup archive needs stronger typical compression than gzip and CPU cost is acceptable. Which utility uses the LZMA2 format?

  1. bzip2 -dc report.bz2
  2. xz
  3. gzip -k access.log
  4. zgrep 'ERROR' access.log.gz

Explanation

Correct Answer

B:

xz uses the LZMA2 compression format and often provides high compression ratios. Compression speed and memory use can differ from gzip.

Incorrect Answers

A:

bzip2 can decompress to stdout with -dc rather than writing a recovered file; the administrator instead needs applying LZMA2 compression; this option serves a different purpose.

C:

gzip compresses a file and -k keeps the source rather than deleting it; that changes a different part of the system; the requested outcome is applying LZMA2 compression.

D:

zgrep decompresses gzip data for pattern matching and reports matching records; this does not achieve applying LZMA2 compression on the system described.

Question 147

A list of relative filenames generated by find must be archived using null delimiters. Which utility can read file lists in cpio format?

  1. cpio -o --null
  2. tar -xf backup.tar etc/hosts
  3. tar -tf backup.tar
  4. tar -xf backup.tar -C /restore

Explanation

Correct Answer

A:

cpio can create an archive from pathnames on stdin, and --null supports null-terminated names. This handles unusual filename characters safely with a matching find -print0 pipeline.

Incorrect Answers

B:

Supplying a member name after the archive selects that specific entry for extraction; the requirement is archiving a null-delimited list of paths, outside the effect of this choice.

C:

tar -t lists member names without writing archived files to disk; it does not deliver archiving a null-delimited list of paths, which is decisive in this scenario.

D:

The -C option changes the extraction target before processing members; the evidence calls for archiving a null-delimited list of paths, not merely this separate operation.

Question 148

An image of a small raw block device must be copied byte for byte to a file. Which tool can perform the operation?

  1. rsync --delete
  2. rsync -a -e ssh src/ host:/backup/
  3. zless access.log.gz
  4. dd if=/dev/sdb of=disk.img bs=4M status=progress
  5. ddrescue with a mapfile

Explanation

Correct Answer

D:

dd copies raw blocks from an input device to an output file without interpreting the filesystem. Input and output paths must be checked because an incorrect target can destroy data.

Incorrect Answers

A:

The --delete option removes destination-side files absent from the source within the synchronized scope; its scope differs from capturing raw device bytes into an image, so it cannot meet the stated requirement.

B:

rsync -a preserves many file attributes and can transfer only changed data over SSH; that is not equivalent to capturing raw device bytes into an image.

C:

zless presents decompressed gzip text through a pager; the administrator instead needs capturing raw device bytes into an image; this option serves a different purpose.

E:

GNU ddrescue tracks which disk sectors were copied or failed in a mapfile; that changes a different part of the system; the requested outcome is capturing raw device bytes into an image.

Question 149

A nightly synchronization should remove files at the destination that no longer exist at the source. Which rsync option is needed?

  1. rsync --delete
  2. ddrescue with a mapfile
  3. zless access.log.gz
  4. rsync -a -e ssh src/ host:/backup/

Explanation

Correct Answer

A:

The --delete option removes destination-side files absent from the source within the synchronized scope. It must be verified carefully to avoid unintended data loss.

Incorrect Answers

B:

GNU ddrescue tracks which disk sectors were copied or failed in a mapfile; it will not provide maintaining a mirror including removals under these conditions.

C:

zless presents decompressed gzip text through a pager; using it would leave maintaining a mirror including removals unresolved.

D:

rsync -a preserves many file attributes and can transfer only changed data over SSH; the requirement is maintaining a mirror including removals, outside the effect of this choice.

Question 150

An engineer needs to revert a laboratory VM to a known prior point after experiments. Which VM capability is useful?

  1. NAT virtual network
  2. Virtual machine snapshot
  3. Bridged networking
  4. Live migration

Explanation

Correct Answer

B:

A snapshot records a recoverable point-in-time VM state as supported by the hypervisor and storage backend. It is not a substitute for off-host backups.

Incorrect Answers

A:

NAT lets guests access external networks by translating source addresses through the host; the evidence calls for reverting a test guest to a saved state, not merely this separate operation.

C:

A bridge attaches a guest interface to the physical network's broadcast domain; its scope differs from reverting a test guest to a saved state, so it cannot meet the stated requirement.

D:

Live migration moves a running VM's execution state to another suitable host; that is not equivalent to reverting a test guest to a saved state.

CompTIA Linux+ (XK0-006) Practice Tests