LPI 102-500 Practice Test 9
Question 80
A helpdesk escalation describes this Linux behavior: A deployment uses command1 AND command2 and expects command2 to run even when command1 fails its exit status. Which TWO complementary steps provide the best corrective action and its most direct diagnostic verification? Select TWO answers.
- Check the immediately relevant command exit code and use && for success-dependent steps and || for failure fallback, grouping commands where precedence matters.
- Check the shell invocation mode, inspect /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile and ~/.bashrc, and compare command resolution in fresh login and non-login sessions.
- Maintain approved default dotfiles and directory templates under /etc/skel and use the appropriate account-creation option to populate new home directories.
- Run controlled success and failure commands, display or capture $?, inspect && and || order, and observe which branch actually executes.
- Assume `&&` always runs both commands and `||` always runs its fallback regardless of the previous program's return status.
Explanation
Correct Answers
A:Recommended administrative action: Check the immediately relevant command exit code and use && for success-dependent steps and || for failure fallback, grouping commands where precedence matters. Linux principle: In Bourne-style shells an exit status of zero signals success, while && and || short-circuit on the preceding command-list status rather than on an unrelated later line.
D:Most direct verification evidence: Run controlled success and failure commands, display or capture $?, inspect && and || order, and observe which branch actually executes. Linux principle: In Bourne-style shells an exit status of zero signals success, while && and || short-circuit on the preceding command-list status rather than on an unrelated later line.
Incorrect Answers
B:This alternative addresses Bash login and interactive startup files, not the specific issue of Shell exit status and AND OR command lists: Check the shell invocation mode, inspect /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile and ~/.bashrc, and compare command resolution in fresh login and non-login sessions. Linux principle: In Bourne-style shells an exit status of zero signals success, while && and || short-circuit on the preceding command-list status rather than on an unrelated later line.
C:That option would maintain approved default dotfiles and directory templates under /etc/skel and use the appropriate account-creation option to populate new home directories, but it addresses a different concern. In Bourne-style shells an exit status of zero signals success, while && and || short-circuit on the preceding command-list status rather than on an unrelated later line.
E:This shortcut is unsafe for the present Linux issue: Assume `&&` always runs both commands and `||` always runs its fallback regardless of the previous program's return status. In Bourne-style shells an exit status of zero signals success, while && and || short-circuit on the preceding command-list status rather than on an unrelated later line.
Question 81
An operations handoff identifies this problem: A script computes a count using $(grep -c ...) but compares it as text with the wrong operator and misclassifies zero matches. Which administrative step is the MOST appropriate way to resolve this issue? Select ONE best answer.
- Maintain approved default dotfiles and directory templates under /etc/skel and use the appropriate account-creation option to populate new home directories.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
- Capture command output using $(...) and test values with appropriate quoted strings or validated numeric operands and conditional syntax.
- Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate.
Explanation
Correct Answer
C:Recommended administrative action: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. ) but compares it as text with the wrong operator and misclassifies zero matches.
Incorrect Answers
A:That option would maintain approved default dotfiles and directory templates under /etc/skel and use the appropriate account-creation option to populate new home directories, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
B:That option would use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
D:That option would use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Question 82
A team maintaining a Linux host reports: A script computes a count using $(grep -c ...) but compares it as text with the wrong operator and misclassifies zero matches. Which Linux behavior or technical principle BEST explains why the issue occurs? Select ONE best answer.
- In Bourne-style shells an exit status of zero signals success, while && and || short-circuit on the preceding command-list status rather than on an unrelated later line.
- Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
- Bash login and interactive non-login shells read different startup files; ~/.bashrc is typically for interactive non-login behavior, while login startup uses a preferred profile file.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
Explanation
Correct Answer
B:Relevant Linux operating principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. ) but compares it as text with the wrong operator and misclassifies zero matches.
Incorrect Answers
A:This alternative addresses Shell exit status and AND OR command lists, not the specific issue of Command substitution tests and numeric conditions: In Bourne-style shells an exit status of zero signals success, while && and || short-circuit on the preceding command-list status rather than on an unrelated later line. ) but compares it as text with the wrong operator and misclassifies zero matches. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
C:This alternative addresses Bash login and interactive startup files, not the specific issue of Command substitution tests and numeric conditions: Bash login and interactive non-login shells read different startup files; ~/.bashrc is typically for interactive non-login behavior, while login startup uses a preferred profile file. ) but compares it as text with the wrong operator and misclassifies zero matches. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
D:That option would use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test, but it addresses a different concern. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
Question 83
While verifying a Linux change request, an engineer finds: A script computes a count using $(grep -c ...) but compares it as text with the wrong operator and misclassifies zero matches. Which evidence or command result MOST directly tests the suspected root cause? Select ONE best answer.
- Check substitution output, command return status, test expression operands and both empty and positive numeric cases.
- Inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation.
- Inspect /etc/skel permissions and contents, review useradd home-creation settings, then create a controlled test account and compare its new home.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
Explanation
Correct Answer
A:Most direct verification evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. ) but compares it as text with the wrong operator and misclassifies zero matches.
Incorrect Answers
B:That option would inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
C:That option would inspect /etc/skel permissions and contents, review useradd home-creation settings, then create a controlled test account and compare its new home, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
D:This shortcut is unsafe for the present Linux issue: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. It cannot establish a safe correction.
Question 84
A Linux administrator investigates the following system incident: A script computes a count using $(grep -c ...) but compares it as text with the wrong operator and misclassifies zero matches. Which observed outcome BEST confirms a successful and properly scoped correction? Select ONE best answer.
- The success path executes only after a zero exit status and the failure notification executes only for intended errors.
- A newly created test user receives the intended accessible default files with correct ownership, while existing homes remain unchanged unless explicitly migrated.
- The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
Explanation
Correct Answer
C:Observable acceptance criterion: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step. ) but compares it as text with the wrong operator and misclassifies zero matches.
Incorrect Answers
A:This alternative addresses Shell exit status and AND OR command lists, not the specific issue of Command substitution tests and numeric conditions: The success path executes only after a zero exit status and the failure notification executes only for intended errors. ) but compares it as text with the wrong operator and misclassifies zero matches. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
B:This alternative addresses Account skeleton directory and default dotfiles, not the specific issue of Command substitution tests and numeric conditions: A newly created test user receives the intended accessible default files with correct ownership, while existing homes remain unchanged unless explicitly migrated. ) but compares it as text with the wrong operator and misclassifies zero matches. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
D:This shortcut is unsafe for the present Linux issue: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. ) but compares it as text with the wrong operator and misclassifies zero matches.
Question 85
On a production Linux workstation or server, a technician observes: A script computes a count using $(grep -c ...) but compares it as text with the wrong operator and misclassifies zero matches. Which misleading assumption MOST directly contributes to this failure and should be rejected? Select ONE best answer.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Assume every script ending in .sh is run by Bash automatically and that readable script files are always executable using ./script.sh.
- Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
Explanation
Correct Answer
D:Reject this specific misconception: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. It incorrectly assumes behavior that conflicts with the observed Linux conditions.
Incorrect Answers
A:This alternative addresses Quoting expansions in file-processing loops, not the specific issue of Command substitution tests and numeric conditions: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. ) but compares it as text with the wrong operator and misclassifies zero matches. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
B:That option would assume every script ending in .sh is run by Bash automatically and that readable script files are always executable using ./script.sh, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
C:That option would treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Question 86
During an LPIC-1 practice lab, the operator encounters this condition: A monitoring script evaluates `[ $items -gt 0 ]` while items is unset and reports a confusing unary-operator error. Which administrative step is the MOST appropriate way to resolve this issue? Select ONE best answer.
- Capture command output using $(...) and test values with appropriate quoted strings or validated numeric operands and conditional syntax.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
- Set a correct interpreter line such as #!/usr/bin/env bash where appropriate and grant execute permission only to intended users while preserving safe file ownership.
- Define and export or source an appropriate Bash function when reusable parameterized behavior is needed; use aliases for simple interactive substitutions and verify command lookup.
Explanation
Correct Answer
A:Recommended administrative action: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Incorrect Answers
B:This shortcut is unsafe for the present Linux issue: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
C:That option would set a correct interpreter line such as #!/usr/bin/env bash where appropriate and grant execute permission only to intended users while preserving safe file ownership, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
D:That option would define and export or source an appropriate Bash function when reusable parameterized behavior is needed; use aliases for simple interactive substitutions and verify command lookup, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Question 87
A helpdesk escalation describes this Linux behavior: A monitoring script evaluates `[ $items -gt 0 ]` while items is unset and reports a confusing unary-operator error. Which Linux behavior or technical principle BEST explains why the issue occurs? Select ONE best answer.
- The skeleton directory provides initial content when a home directory is created; changing an existing user's home does not update the account template or existing users automatically.
- Shell variable assignment is local until exported to children; child processes cannot ordinarily modify their parent's environment, and PATH search order determines executed binaries.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
- Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Explanation
Correct Answer
D:Relevant Linux operating principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Incorrect Answers
A:This alternative addresses Account skeleton directory and default dotfiles, not the specific issue of Command substitution tests and numeric conditions: The skeleton directory provides initial content when a home directory is created; changing an existing user's home does not update the account template or existing users automatically. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
B:This alternative addresses Safe PATH changes and environment export, not the specific issue of Command substitution tests and numeric conditions: Shell variable assignment is local until exported to children; child processes cannot ordinarily modify their parent's environment, and PATH search order determines executed binaries. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
C:This shortcut is unsafe for the present Linux issue: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. It cannot establish a safe correction. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Question 88
An operations handoff identifies this problem: A monitoring script evaluates `[ $items -gt 0 ]` while items is unset and reports a confusing unary-operator error. Which evidence or command result MOST directly tests the suspected root cause? Select ONE best answer.
- Inspect /etc/skel permissions and contents, review useradd home-creation settings, then create a controlled test account and compare its new home.
- Check substitution output, command return status, test expression operands and both empty and positive numeric cases.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
- Use type for the name, display the function or alias definition, and invoke a new shell to test whether the intended definition is available there.
Explanation
Correct Answer
B:Most direct verification evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Incorrect Answers
A:This alternative addresses Account skeleton directory and default dotfiles, not the specific issue of Command substitution tests and numeric conditions: Inspect /etc/skel permissions and contents, review useradd home-creation settings, then create a controlled test account and compare its new home.
C:This shortcut is unsafe for the present Linux issue: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. It cannot establish a safe correction. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
D:That option would use type for the name, display the function or alias definition, and invoke a new shell to test whether the intended definition is available there, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Question 89
A team maintaining a Linux host reports: A monitoring script evaluates `[ $items -gt 0 ]` while items is unset and reports a confusing unary-operator error. Which observed outcome BEST confirms a successful and properly scoped correction? Select ONE best answer.
- The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
- Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.
- The success path executes only after a zero exit status and the failure notification executes only for intended errors.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
Explanation
Correct Answer
A:Observable acceptance criterion: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Incorrect Answers
B:This alternative addresses Bash functions versus aliases and command lookup, not the specific issue of Command substitution tests and numeric conditions: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
C:This alternative addresses Shell exit status and AND OR command lists, not the specific issue of Command substitution tests and numeric conditions: The success path executes only after a zero exit status and the failure notification executes only for intended errors. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts. Appropriate response: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Root-cause evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Independent acceptance: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
D:This shortcut is unsafe for the present Linux issue: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Question 90
While verifying a Linux change request, an engineer finds: A monitoring script evaluates `[ $items -gt 0 ]` while items is unset and reports a confusing unary-operator error. Which TWO complementary steps provide the best corrective action and its most direct diagnostic verification? Select TWO answers.
- Capture command output using $(...) and test values with appropriate quoted strings or validated numeric operands and conditional syntax.
- Check the immediately relevant command exit code and use && for success-dependent steps and || for failure fallback, grouping commands where precedence matters.
- Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test.
- Check substitution output, command return status, test expression operands and both empty and positive numeric cases.
- Check the shell invocation mode, inspect /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile and ~/.bashrc, and compare command resolution in fresh login and non-login sessions.
Explanation
Correct Answers
A:Recommended administrative action: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
D:Most direct verification evidence: Check substitution output, command return status, test expression operands and both empty and positive numeric cases. Linux principle: Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
Incorrect Answers
B:That option would check the immediately relevant command exit code and use && for success-dependent steps and || for failure fallback, grouping commands where precedence matters, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
C:This shortcut is unsafe for the present Linux issue: Use textual equality for every numeric comparison and rely on unquoted empty variables to supply a valid argument to test. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.
E:That option would check the shell invocation mode, inspect /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile and ~/.bashrc, and compare command resolution in fresh login and non-login sessions, but it addresses a different concern. Command substitution inserts command standard output, while test operators distinguish numeric and string comparisons and missing unquoted variables can corrupt argument counts.