100% Latest & Updated LPI 102-500 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 100
An operator tests an optional shell variable without quoting it and gets a unary-operator error when it is empty. Which THREE case-specific steps cover immediate repair, test evidence and sustained control?
- Require quoting of variable expansions in portable test commands.
- Run the script with the parameter empty, unset and populated to verify branching.
- Use [ -n "$value" ] or a Bash-native conditional that handles empty strings safely.
- Put login-wide settings in /etc/profile or an applicable profile.d snippet, considering the distribution's startup arrangement.
- Maintain global login configuration centrally rather than copying account-specific dotfiles.
- Open a new ordinary terminal and use type to verify the alias is visible.
Explanation
Correct Answers
A:Require quoting of variable expansions in portable test commands. It preserves the corrective behavior established through: Use [ -n "$value" ] or a Bash-native conditional that handles empty strings safely.
B:Run the script with the parameter empty, unset and populated to verify branching. This measures the specific result of applying: Use [ -n "$value" ] or a Bash-native conditional that handles empty strings safely.
C:Use [ -n "$value" ] or a Bash-native conditional that handles empty strings safely. This is appropriate because An unquoted empty expansion removes an argument from the test expression.
Incorrect Answers
D:Put login-wide settings in /etc/profile or an applicable profile.d snippet, considering the distribution's startup arrangement. could help with shared shell initialization; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Run the script with the parameter empty, unset and populated to verify branching.
E:That choice responds to a shared shell initialization failure. In this incident, An unquoted empty expansion removes an argument from the test expression.
F:Open a new ordinary terminal and use type to verify the alias is visible. could help with nonlogin terminal startup; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Run the script with the parameter empty, unset and populated to verify branching.
Question 101
A team sets the setuid bit on an ordinary shell script expecting unprivileged callers to gain root rights, but privilege does not change. What underlying Linux behavior should the administrator identify first?
- A function defined in one shell is not automatically a function in an unrelated child shell.
- Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
- An already exported variable remains in the current process environment until unset or the shell is replaced.
- Bash reads the first readable per-user login profile in its defined order, so ~/.bash_profile prevents ~/.profile from being read.
Explanation
Correct Answer
B:Linux generally ignores setuid elevation on interpreter scripts because it is unsafe. The administrator should distinguish this from unrelated symptoms by checking: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
Incorrect Answers
A:A function defined in one shell is not automatically a function in an unrelated child shell. That describes a different fault. Here, Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
C:This belongs to startup environment removal, where An already exported variable remains in the current process environment until unset or the shell is replaced. The current issue instead is: Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
D:The test for bash login profile precedence would be: Start a fresh bash login shell and inspect PATH after tracing which profile was read. The relevant acceptance check here is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
Question 102
A team sets the setuid bit on an ordinary shell script expecting unprivileged callers to gain root rights, but privilege does not change. What action should be planned as the next targeted correction?
- Remove empty PATH components and use an explicit trusted directory list instead.
- Run narrowly scoped privileged operations through a reviewed sudo policy or a dedicated privileged service instead.
- Put the approved executable directory before the conflicting directory or invoke its absolute path.
- Move the intended PATH export into ~/.bash_profile or deliberately source ~/.profile from it.
Explanation
Correct Answer
B:Run narrowly scoped privileged operations through a reviewed sudo policy or a dedicated privileged service instead. It corrects the mechanism identified in the scenario: Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
Incorrect Answers
A:The test for inherited empty path entry would be: Inspect PATH for leading, trailing or adjacent colons and test command -v from a writable directory. The relevant acceptance check here is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
C:It would address command lookup path ordering rather than the present problem. The appropriate correction here is: Run narrowly scoped privileged operations through a reviewed sudo policy or a dedicated privileged service instead.
D:Move the intended PATH export into ~/.bash_profile or deliberately source ~/.profile from it. could help with bash login profile precedence; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
Question 103
A team sets the setuid bit on an ordinary shell script expecting unprivileged callers to gain root rights, but privilege does not change. What diagnostic result would demonstrate the target behavior?
- Start the intended type of new Bash shell and run type deploy to confirm function availability.
- Use type -a audit and command -v audit to inspect every candidate and the selected path.
- Create a test account, inspect its copied dotfiles and verify ownership belongs to the new user.
- Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
Explanation
Correct Answer
D:Check effective identity during a controlled run and confirm unauthorized users cannot escalate. The test is evidence-based because the underlying failure was: Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
Incorrect Answers
A:The test for function available only in parent would be: Start the intended type of new Bash shell and run type deploy to confirm function availability. The relevant acceptance check here is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
B:The test for command lookup path ordering would be: Use type -a audit and command -v audit to inspect every candidate and the selected path. The relevant acceptance check here is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
C:This option assumes New home-directory defaults come from the configured skeleton directory, not an existing user's home. The reported symptoms instead call for: Run narrowly scoped privileged operations through a reviewed sudo policy or a dedicated privileged service instead.
Question 104
A team sets the setuid bit on an ordinary shell script expecting unprivileged callers to gain root rights, but privilege does not change. What operational safeguard addresses the root cause?
- Keep interactive-only customizations in bashrc and test both login and non-login shells.
- Ban setuid shell-script designs in security reviews and test execution paths under least privilege.
- Maintain global login configuration centrally rather than copying account-specific dotfiles.
- Use command-scoped environment overrides for reproducible automation and preserve user defaults.
Explanation
Correct Answer
B:Ban setuid shell-script designs in security reviews and test execution paths under least privilege. It makes the outcome of the targeted repair (Run narrowly scoped privileged operations through a reviewed sudo policy or a dedicated privileged service instead.) repeatable.
Incorrect Answers
A:Keep interactive-only customizations in bashrc and test both login and non-login shells. could help with nonlogin terminal startup; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
C:This belongs to shared shell initialization, where Per-user Bash startup files cannot reliably configure all login users across the host. The current issue instead is: Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
D:Use command-scoped environment overrides for reproducible automation and preserve user defaults. could help with one command environment override; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
Question 105
A team sets the setuid bit on an ordinary shell script expecting unprivileged callers to gain root rights, but privilege does not change. Select TWO justified actions that address this particular problem and confirm closure.
- Run narrowly scoped privileged operations through a reviewed sudo policy or a dedicated privileged service instead.
- Keep interactive-only customizations in bashrc and test both login and non-login shells.
- Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
- Start a fresh bash login shell and inspect PATH after tracing which profile was read.
- Export REPORT_ROOT after assigning it, or prefix the one child command with its environment assignment.
Explanation
Correct Answers
A:Run narrowly scoped privileged operations through a reviewed sudo policy or a dedicated privileged service instead. It addresses the root cause, while Ban setuid shell-script designs in security reviews and test execution paths under least privilege. reduces future recurrence.
C:Check effective identity during a controlled run and confirm unauthorized users cannot escalate. It distinguishes a genuine correction from a superficial edit that has not addressed the underlying cause: Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
Incorrect Answers
B:This belongs to nonlogin terminal startup, where Interactive non-login Bash reads ~/.bashrc rather than the login profile by default. The current issue instead is: Linux generally ignores setuid elevation on interpreter scripts because it is unsafe.
D:Start a fresh bash login shell and inspect PATH after tracing which profile was read. belongs to a situation where Bash reads the first readable per-user login profile in its defined order, so ~/.bash_profile prevents ~/.profile from being read. Here the evidence supports a different requirement: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
E:Export REPORT_ROOT after assigning it, or prefix the one child command with its environment assignment. could help with child process inherited variable; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Check effective identity during a controlled run and confirm unauthorized users cannot escalate.
Question 106
A monitoring script checks $? after echoing a diagnostic line, so it always records success even when the monitored command failed. Which mechanism best explains the difference between expectation and result?
- New home-directory defaults come from the configured skeleton directory, not an existing user's home.
- Interactive non-login Bash reads ~/.bashrc rather than the login profile by default.
- The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
- Editing a startup file changes what future shells read; it does not rewrite the running shell's variables.
Explanation
Correct Answer
C:The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it. A good follow-up is to test this explanation through: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
Incorrect Answers
A:That choice responds to a new account skeleton content failure. In this incident, The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
B:That choice responds to a nonlogin terminal startup failure. In this incident, The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
D:That choice responds to a execute profile in current process failure. In this incident, The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
Question 107
A monitoring script checks $? after echoing a diagnostic line, so it always records success even when the monitored command failed. What action should be planned as the next targeted correction?
- Source ~/.bashrc in the current compatible Bash shell, then launch the dependent command.
- Capture status=$? immediately after the monitored command before printing further output.
- Put the approved executable directory before the conflicting directory or invoke its absolute path.
- Run LANG=C followed by the intended command so the assignment is scoped to that invocation.
Explanation
Correct Answer
B:Capture status=$? immediately after the monitored command before printing further output. The change should be accepted only after this test: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
Incorrect Answers
A:Source ~/.bashrc in the current compatible Bash shell, then launch the dependent command. could help with execute profile in current process; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
C:Put the approved executable directory before the conflicting directory or invoke its absolute path. could help with command lookup path ordering; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
D:Exporting LANG globally to the shell would affect subsequent children, not just the single build execution. That describes a different fault. Here, The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
Question 108
A monitoring script checks $? after echoing a diagnostic line, so it always records success even when the monitored command failed. Which check would provide the strongest evidence that the fix worked?
- Test fresh login shells for two different accounts and inspect the exported variable.
- Force a nonzero monitored result and confirm the captured value is unchanged after logging.
- Print LANG in the build subprocess and again afterward in the parent shell.
- Check env in both the current shell and a fresh login shell to confirm the variable is absent.
Explanation
Correct Answer
B:Force a nonzero monitored result and confirm the captured value is unchanged after logging. The observation confirms the diagnosis or falsifies it before declaring the incident resolved.
Incorrect Answers
A:It would address shared shell initialization rather than the present problem. The appropriate correction here is: Capture status=$? immediately after the monitored command before printing further output.
C:Exporting LANG globally to the shell would affect subsequent children, not just the single build execution. That describes a different fault. Here, The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
D:Check env in both the current shell and a fresh login shell to confirm the variable is absent. could help with startup environment removal; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
Question 109
A monitoring script checks $? after echoing a diagnostic line, so it always records success even when the monitored command failed. Which practice is most useful after the immediate repair succeeds?
- Maintain global login configuration centrally rather than copying account-specific dotfiles.
- Document which login startup file owns environment customization and avoid conflicting definitions.
- Audit whether task variables need to be shell-local or exported to child processes.
- Place exit-status capture adjacent to the command it evaluates.
Explanation
Correct Answer
D:Place exit-status capture adjacent to the command it evaluates. The underlying risk is The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
Incorrect Answers
A:The test for shared shell initialization would be: Test fresh login shells for two different accounts and inspect the exported variable. The relevant acceptance check here is: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
B:This option assumes Bash reads the first readable per-user login profile in its defined order, so ~/.bash_profile prevents ~/.profile from being read. The reported symptoms instead call for: Capture status=$? immediately after the monitored command before printing further output.
C:That choice responds to a child process inherited variable failure. In this incident, The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
Question 110
A monitoring script checks $? after echoing a diagnostic line, so it always records success even when the monitored command failed. Which THREE actions form a suitable remediation, verification and prevention plan? Select THREE.
- Inspect PATH for leading, trailing or adjacent colons and test command -v from a writable directory.
- Force a nonzero monitored result and confirm the captured value is unchanged after logging.
- Capture status=$? immediately after the monitored command before printing further output.
- Avoid untrusted writable directories ahead of system binaries in PATH.
- Put the approved executable directory before the conflicting directory or invoke its absolute path.
- Place exit-status capture adjacent to the command it evaluates.
Explanation
Correct Answers
B:Force a nonzero monitored result and confirm the captured value is unchanged after logging. The observation confirms the diagnosis or falsifies it before declaring the incident resolved.
C:Capture status=$? immediately after the monitored command before printing further output. This is appropriate because The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
F:Place exit-status capture adjacent to the command it evaluates. Sustained checks matter because The special parameter $? reports the immediately preceding command's exit status, and echo overwrote it.
Incorrect Answers
A:Inspect PATH for leading, trailing or adjacent colons and test command -v from a writable directory. belongs to a situation where An empty component in PATH can cause the current working directory to be searched in command lookup. Here the evidence supports a different requirement: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
D:Avoid untrusted writable directories ahead of system binaries in PATH. could help with command lookup path ordering; it neither resolves nor demonstrates the current requirement. The distinguishing check is: Force a nonzero monitored result and confirm the captured value is unchanged after logging.
E:This option assumes Command lookup follows the order of directories in PATH, not the newest version of an executable. The reported symptoms instead call for: Capture status=$? immediately after the monitored command before printing further output.
LPI Level 1 (102-500) Practice Tests