CompTIA Linux+ (XK0-006) — All Questions

← Back to practice

3 questions

Automation, Orchestration & Scripting

In a bash script, which variable holds the exit status of the most recently executed command?

  • a.$#
  • b.$?
  • c.$!
  • d.$0

'$?' contains the exit status of the last command, where 0 means success and non-zero indicates an error. '$#' is the argument count, '$!' is the PID of the last background job, and '$0' is the script name.

Automation, Orchestration & Scripting

Which cron schedule expression runs a job every day at 2:30 AM?

  • a.30 2 * * *
  • b.* 2 30 * *
  • c.2 30 * * *
  • d.30 2 * * 0

Cron fields are minute, hour, day-of-month, month, day-of-week, so '30 2 * * *' means minute 30 of hour 2 every day. '30 2 * * 0' would restrict it to Sundays, and the other orderings misplace the minute and hour fields.

Automation, Orchestration & Scripting

In Ansible, which characteristic describes a well-written task that can run repeatedly without changing the result after the first successful run?

  • a.Imperative
  • b.Ephemeral
  • c.Idempotent
  • d.Stateful

Idempotency means applying the same task multiple times yields the same end state, so Ansible only makes changes when the system differs from the desired state. This is a core principle of infrastructure-as-code that prevents unintended repeated modifications.

Report