Question 410
The lab examiner asks for evidence after this assignment: A daily job must print only directories under a sample tree but currently loops through both files and directories. What is the decisive verification step?
Explanation
Correct Answer
Only directory entries appear while ordinary files are skipped. This check confirms the expected effect of: Use `for path in /tmp/lab-tree/*; do [ -d "$path" ] || continue; printf '%s\n' "$path"; done`. It distinguishes the intended result from the original failure mechanism: A wildcard expands all matching entries; the `-d` test discriminates directories.
Incorrect Answers
The script runs under a restricted environment and resolves required binaries. That verifies a separate lab task: A cron-invoked script prints `command not found` for a utility present in the interactive user's shell. It does not validate the implementation required here: Use `for path in /tmp/lab-tree/*; do [ -d "$path" ] || continue; printf '%s\n' "$path"; done`.
The printed host label matches `hostname -s` without treating it as an executable. That verifies a separate lab task: A shell script writes raw command output but needs its first line to include the current hostname from the target host. It does not validate the implementation required here: Use `for path in /tmp/lab-tree/*; do [ -d "$path" ] || continue; printf '%s\n' "$path"; done`.
The output contains one result per unit and no unrequested service is started. That verifies a separate lab task: A service check is intended to poll five named systemd units, but the script uses only the first literal unit. It does not validate the implementation required here: Use `for path in /tmp/lab-tree/*; do [ -d "$path" ] || continue; printf '%s\n' "$path"; done`.