Linux+ XK0-006 practice question 10: Automation
A shell script should stop immediately if any command fails, rather than carrying on with bad data. Which line near the top does this?
The options
- A. set -e
- B. set +x
- C. unset HISTFILE
- D. export PATH
Answer and why
The correct answer is A: set -e
A. set -e makes the shell exit when a command returns a non-zero status.
B. This turns off command tracing and does not stop on errors.
C. This stops saving history and has no effect on failures.
D. Exporting a variable does not change how errors are handled.
What Automation tests
Automation, orchestration and scripting covers shell scripts, version control, configuration management and infrastructure as code. Look for the idiom that makes a script safe and repeatable rather than merely working once.
Automation, orchestration, and scripting is 17% of the XK0-006 exam. The exam has 90 questions in 90 minutes, so this question is a slice of the real mix, not a prediction of your result.
Try these next
Each one is a free question from the same practice test, with the answer and the reason for every option on its own page.
- A team wants to track changes to configuration files, review them before they apply and roll back easily. Which practice supports this?
- A configuration management run is applied to a server twice and the second run makes no changes. Which property does this show?
- An administrator needs to see which block devices are attached, with their sizes and mount points, in a tree. Which command does that?
- A new disk partition has been formatted and must be mounted at boot. Which file should the administrator add an entry to?
Keep going
This is question 10 of 15 in the free Linux+ XK0-006 practice test. If you missed it, say why in one sentence before you read on: the reason is what transfers to a differently worded question.