Question 210
In a hands-on RHCSA practice VM, the assigned outcome was: A service check is intended to poll five named systemd units, but the script uses only the first literal unit. What specific verification would demonstrate the target state?
Explanation
Correct Answer
The output contains one result per unit and no unrequested service is started. This check confirms the expected effect of: Use `for unit in sshd crond chronyd firewalld NetworkManager; do systemctl is-active "$unit"; done`. It distinguishes the intended result from the original failure mechanism: A `for` loop explicitly processes each named input rather than repeating one static check.
Incorrect Answers
A normal VM prints `present`; a fixture with a missing file returns a nonzero exit. That verifies a separate lab task: A lab script must exit successfully only when `/etc/hosts` exists, but an unguarded command reports success in both cases. It does not validate the implementation required here: Use `for unit in sshd crond chronyd firewalld NetworkManager; do systemctl is-active "$unit"; done`.
Known values 9 and 10 route to different expected branches. That verifies a separate lab task: A script's `if` statement tests a numeric threshold using string comparison and misorders the values 9 and 10. It does not validate the implementation required here: Use `for unit in sshd crond chronyd firewalld NetworkManager; do systemctl is-active "$unit"; done`.
`head -n 1 script` shows the interpreter and direct execution uses the expected Bash features. That verifies a separate lab task: A shell helper is executed with `/bin/sh` but contains Bash-only syntax and fails on an alternate POSIX shell. It does not validate the implementation required here: Use `for unit in sshd crond chronyd firewalld NetworkManager; do systemctl is-active "$unit"; done`.