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

Question 170

A deployment tool should create several nested directories even if parents are absent. Which command is suitable?

  1. find /srv -type f -mtime -1
  2. ls -ld /srv/data
  3. mkdir -p /srv/app/cache
  4. mv old.csv new.csv

Explanation

Correct Answer

C:

mkdir -p creates missing parent directories and does not fail merely because an existing directory is already present. It does not recursively change ownership.

Incorrect Answers

A:

find walks a directory tree and evaluates predicates for file type and modification time; the administrator instead needs creating a nested directory tree safely; this option serves a different purpose.

B:

ls -ld displays long-format metadata about the directory entry; it answers a neighboring question rather than creating a nested directory tree safely.

D:

mv renames or relocates files and can use a filesystem rename when source and target are on the same filesystem; this does not achieve creating a nested directory tree safely on the system described.

Question 171

Two directory entries should point to the same inode of a regular file on one filesystem. Which command creates the second entry?

  1. Symbolic linkage rather than hard linkage
  2. readlink symlink
  3. The inode remains while another hard link exists
  4. ln original hardcopy

Explanation

Correct Answer

D:

A hard link adds another directory entry referencing the same inode and data. It cannot normally cross filesystem boundaries and does not work for arbitrary directories.

Incorrect Answers

A:

Symlinks can refer across filesystem boundaries because their contents are paths; using it would leave creating another inode name on the same filesystem unresolved.

B:

readlink displays the link target recorded in the symbolic-link inode; the requirement is creating another inode name on the same filesystem, outside the effect of this choice.

C:

Unlinking one name reduces the link count, but data remains accessible through surviving names and open references; it does not deliver creating another inode name on the same filesystem, which is decisive in this scenario.

Question 172

A serial console appears in /dev and processes read bytes in a stream. Which node type is expected?

  1. /dev/zero
  2. Character device
  3. locate filename
  4. lsof +D /mnt/archive

Explanation

Correct Answer

B:

A character device exposes byte-stream operations to a driver, as with serial terminals. It is not necessarily seekable like a block-storage device.

Incorrect Answers

A:

/dev/zero produces zero bytes on reads for requested lengths; its scope differs from identifying a serial terminal's device class, so it cannot meet the stated requirement.

C:

locate searches a filename database quickly rather than traversing the filesystem live; the administrator instead needs identifying a serial terminal's device class; this option serves a different purpose.

D:

lsof reports open files held by processes and can search under a directory; it answers a neighboring question rather than identifying a serial terminal's device class.

Question 173

An administrator is comparing /dev/sda and /dev/ttyS0. Which type is normally associated with disks?

  1. Block device
  2. lsof +D /mnt/archive
  3. /dev/null
  4. locate filename

Explanation

Correct Answer

A:

Block devices support addressable block-oriented I/O suited to disk and partition abstractions. Character devices normally present sequential streams instead.

Incorrect Answers

B:

lsof reports open files held by processes and can search under a directory; it will not provide identifying the disk-style device class under these conditions.

C:

/dev/null accepts and discards writes and returns EOF when read; using it would leave identifying the disk-style device class unresolved.

D:

locate searches a filename database quickly rather than traversing the filesystem live; the requirement is identifying the disk-style device class, outside the effect of this choice.

Question 174

A tool must display the pathname stored in a symlink without following it into the target file. Which utility fits?

  1. Symbolic links store a target path
  2. readlink symlink
  3. ln -s /opt/app/config.yml /etc/app-link.yml
  4. The inode remains while another hard link exists
  5. Symbolic linkage rather than hard linkage

Explanation

Correct Answer

B:

readlink displays the link target recorded in the symbolic-link inode. That value may be relative or point to a nonexistent destination.

Incorrect Answers

A:

A symbolic link resolves its stored path during use rather than retaining the original target inode; the evidence calls for reading the stored symbolic-link target, not merely this separate operation.

C:

A symbolic link stores a pathname and can cross filesystem boundaries; its scope differs from reading the stored symbolic-link target, so it cannot meet the stated requirement.

D:

Unlinking one name reduces the link count, but data remains accessible through surviving names and open references; that is not equivalent to reading the stored symbolic-link target.

E:

Symlinks can refer across filesystem boundaries because their contents are paths; the administrator instead needs reading the stored symbolic-link target; this option serves a different purpose.

Question 175

A report file must be renamed within its current filesystem without reprocessing the bytes. Which command does that?

  1. cp -a source/ destination/
  2. pwd -P
  3. touch -m report.txt
  4. mv old.csv new.csv

Explanation

Correct Answer

D:

mv renames or relocates files and can use a filesystem rename when source and target are on the same filesystem. Across filesystems it may require copying and deleting.

Incorrect Answers

A:

cp -a performs an archive-style recursive copy while preserving many attributes; it answers a neighboring question rather than renaming a file through the filesystem.

B:

pwd -P prints the physical working directory, resolving symbolic components where supported; that changes a different part of the system; the requested outcome is renaming a file through the filesystem.

C:

touch can update specified timestamps without modifying file data; this does not achieve renaming a file through the filesystem on the system described.

Question 176

A technician must find regular files under /srv modified within the past 24 hours. Which command expression fits?

  1. find /srv -type f -mtime -1
  2. ls -ld /srv/data
  3. pwd -P
  4. mv old.csv new.csv

Explanation

Correct Answer

A:

find walks a directory tree and evaluates predicates for file type and modification time. The -mtime -1 test covers the most recent 24-hour interval.

Incorrect Answers

B:

ls -ld displays long-format metadata about the directory entry; it does not deliver locating recently modified regular files recursively, which is decisive in this scenario.

C:

pwd -P prints the physical working directory, resolving symbolic components where supported; the evidence calls for locating recently modified regular files recursively, not merely this separate operation.

D:

mv renames or relocates files and can use a filesystem rename when source and target are on the same filesystem; the task involves locating recently modified regular files recursively, whereas this addresses another subsystem.

Question 177

A process's open file descriptors must be listed to discover which file prevents an unmount. Which utility is suitable?

  1. lsof +D /mnt/archive
  2. /dev/null
  3. Block device
  4. Character device

Explanation

Correct Answer

A:

lsof reports open files held by processes and can search under a directory. A recursive scan may be costly on large trees.

Incorrect Answers

B:

/dev/null accepts and discards writes and returns EOF when read; the administrator instead needs identifying processes with open files in a mount tree; this option serves a different purpose.

C:

Block devices support addressable block-oriented I/O suited to disk and partition abstractions; it answers a neighboring question rather than identifying processes with open files in a mount tree.

D:

A character device exposes byte-stream operations to a driver, as with serial terminals; that changes a different part of the system; the requested outcome is identifying processes with open files in a mount tree.

Question 178

A path lookup utility finds files from a periodically generated database but may miss newly created paths. Which tool is it?

  1. /dev/null
  2. Character device
  3. lsof +D /mnt/archive
  4. locate filename

Explanation

Correct Answer

D:

locate searches a filename database quickly rather than traversing the filesystem live. Results depend on when that database was last updated.

Incorrect Answers

A:

/dev/null accepts and discards writes and returns EOF when read; it will not provide searching indexed filesystem paths under these conditions.

B:

A character device exposes byte-stream operations to a driver, as with serial terminals; using it would leave searching indexed filesystem paths unresolved.

C:

lsof reports open files held by processes and can search under a directory; the requirement is searching indexed filesystem paths, outside the effect of this choice.

Question 179

A directory needs a link that can be moved to another filesystem while retaining a valid target path. Which property matters?

  1. readlink symlink
  2. ln -s /opt/app/config.yml /etc/app-link.yml
  3. Symbolic linkage rather than hard linkage
  4. Symbolic links store a target path

Explanation

Correct Answer

C:

Symlinks can refer across filesystem boundaries because their contents are paths. Hard links must refer to an inode on the same filesystem.

Incorrect Answers

A:

readlink displays the link target recorded in the symbolic-link inode; the task involves choosing a cross-filesystem path reference, whereas this addresses another subsystem.

B:

A symbolic link stores a pathname and can cross filesystem boundaries; its scope differs from choosing a cross-filesystem path reference, so it cannot meet the stated requirement.

D:

A symbolic link resolves its stored path during use rather than retaining the original target inode; the administrator instead needs choosing a cross-filesystem path reference; this option serves a different purpose.

Question 180

A file has two hard links and one pathname is deleted. What normally happens to the underlying data?

  1. Symbolic linkage rather than hard linkage
  2. The inode remains while another hard link exists
  3. readlink symlink
  4. ln -s /opt/app/config.yml /etc/app-link.yml
  5. ln original hardcopy

Explanation

Correct Answer

B:

Unlinking one name reduces the link count, but data remains accessible through surviving names and open references. Removing one hard link does not truncate the other.

Incorrect Answers

A:

Symlinks can refer across filesystem boundaries because their contents are paths; that changes a different part of the system; the requested outcome is preserving inode data after one name is removed.

C:

readlink displays the link target recorded in the symbolic-link inode; it will not provide preserving inode data after one name is removed under these conditions.

D:

A symbolic link stores a pathname and can cross filesystem boundaries; using it would leave preserving inode data after one name is removed unresolved.

E:

A hard link adds another directory entry referencing the same inode and data; the requirement is preserving inode data after one name is removed, outside the effect of this choice.

CompTIA Linux+ (XK0-006) Practice Tests