
LPI Linux Essentials (010-160)
Domain 3Objective 3
3.3 Turning Commands into a Script (weight: 4) LINUX-ESSENTIALS Practice Questions (Page 5)
Part of the Topic 3: The Power of the Command Line domain, which makes up ~16% of our current practice bank. Linux Professional Institute does not publish an official question count, but from its 60-minute exam (~25–40 total, ~4–6 in this domain), expect 1–2 from this objective — we provide 36 practice questions to prepare you well beyond it. (estimate)
36questions here
8free pages
9concepts
Questions 21–25
- 21
A senior admin is debugging a script that processes user input. The script uses 'set -x' at the top. When running the script with an argument 'foo', the trace shows: '+ [ foo = bar ]' and then the script takes the else branch. The admin expected the if branch. What is the most likely issue?
Select an answer first - 22
A script must check if a file exists and is readable, and if so, print its contents. The admin writes: 'if [ -r file.txt ]; then cat file.txt; fi'. However, the script prints nothing even though the file exists and is readable. What is the most likely cause?
Select an answer first - 23
A script needs to process a list of usernames from a file, one per line. The admin uses 'for user in $(cat users.txt); do ...'. The script fails when a username contains a space. What is the best fix?
Select an answer first - 24
A script runs a command that may fail, and the admin wants to exit the script with a specific error code if it fails. The admin writes: 'command || exit 1'. However, the script continues even when the command fails. What is the likely reason?
Select an answer first - 25
A script needs to iterate over a list of numbers from 1 to 10 and print the square of each. The admin writes: 'for i in {1..10}; do echo $((i*i)); done'. The script works, but the admin wants to make the upper limit configurable via a variable. Which approach is correct?
Select an answer first
Finished these 5 questions?
Review the revealed explanations, or continue through the curriculum.
Free Basic Practice is a study aid with revealable answers — not a scored exam. Examers.io is independent and not affiliated with or endorsed by Linux Professional Institute. “LINUX-ESSENTIALS” is a trademark of its owner, used for identification only.