LPI 102-500 Practice Test 7
Question 60
An operations handoff identifies this problem: An operator attempts to execute ./backup.sh and gets permission denied although the file contains valid commands and is readable. Which TWO complementary steps provide the best corrective action and its most direct diagnostic verification? Select TWO answers.
- Inspect /etc/skel permissions and contents, review useradd home-creation settings, then create a controlled test account and compare its new home.
- Inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation.
- Capture command output using $(...) and test values with appropriate quoted strings or validated numeric operands and conditional syntax.
- 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.
- Assume every script ending in .sh is run by Bash automatically and that readable script files are always executable using ./script.sh.
Explanation
Correct Answers
B:Most direct verification evidence: Inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation. Scenario: An operator attempts to execute ./backup.sh and gets permission denied although the file contains valid commands and is readable. Linux principle: The shebang selects the interpreter for direct execution and executable permission controls whether the kernel will launch the file; reading via bash script.sh is a separate execution path.
D:Recommended administrative action: 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. Scenario: An operator attempts to execute ./backup.sh and gets permission denied although the file contains valid commands and is readable. Linux principle: The shebang selects the interpreter for direct execution and executable permission controls whether the kernel will launch the file; reading via bash script.sh is a separate execution path.
Incorrect Answers
A: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. The shebang selects the interpreter for direct execution and executable permission controls whether the kernel will launch the file; reading via bash script.sh is a separate execution path.
C:This alternative addresses Command substitution tests and numeric conditions, not the specific issue of Bash shebang and executable permission: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Scenario: An operator attempts to execute ./backup.sh and gets permission denied although the file contains valid commands and is readable. Linux principle: The shebang selects the interpreter for direct execution and executable permission controls whether the kernel will launch the file; reading via bash script.sh is a separate execution path. Appropriate response: 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. Root-cause evidence: Inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation. Independent acceptance: The file runs under its specified interpreter for authorized users and fails safely for unauthorized execution without relying on a misidentified shell.
E:This shortcut is unsafe for the present Linux issue: Assume every script ending in .sh is run by Bash automatically and that readable script files are always executable using ./script.sh. Scenario: An operator attempts to execute ./backup.sh and gets permission denied although the file contains valid commands and is readable. The shebang selects the interpreter for direct execution and executable permission controls whether the kernel will launch the file; reading via bash script.sh is a separate execution path.
Question 61
A team maintaining a Linux host reports: A nightly script iterates over filenames with spaces using for f in $(ls) and silently splits one filename into multiple arguments. Which administrative step is the MOST appropriate way to resolve this issue? Select ONE best answer.
- Export only required variables and construct a deliberately ordered PATH using trusted absolute directories; source a file when the current shell must receive its changes.
- Capture command output using $(...) and test values with appropriate quoted strings or validated numeric operands and conditional syntax.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- 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
D:Recommended administrative action: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate.
Incorrect Answers
A:This alternative addresses Safe PATH changes and environment export, not the specific issue of Quoting expansions in file-processing loops: Export only required variables and construct a deliberately ordered PATH using trusted absolute directories; source a file when the current shell must receive its changes. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
B:This alternative addresses Command substitution tests and numeric conditions, not the specific issue of Quoting expansions in file-processing loops: Capture command output using $(.) and test values with appropriate quoted strings or validated numeric operands and conditional syntax. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
C:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. It cannot establish a safe correction. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Question 62
While verifying a Linux change request, an engineer finds: A nightly script iterates over filenames with spaces using for f in $(ls) and silently splits one filename into multiple arguments. Which Linux behavior or technical principle BEST explains why the issue occurs? Select ONE best answer.
- 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.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
- Sourcing executes shell statements in the current process, whereas launching a new process isolates its environment; an empty variable still exists until removed.
Explanation
Correct Answer
C:Relevant Linux operating principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
Incorrect Answers
A:This alternative addresses Safe PATH changes and environment export, not the specific issue of Quoting expansions in file-processing loops: 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: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
B:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
D:This alternative addresses Sourcing shell settings and removing variables, not the specific issue of Quoting expansions in file-processing loops: Sourcing executes shell statements in the current process, whereas launching a new process isolates its environment; an empty variable still exists until removed. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Question 63
A Linux administrator investigates the following system incident: A nightly script iterates over filenames with spaces using for f in $(ls) and silently splits one filename into multiple arguments. Which evidence or command result MOST directly tests the suspected root cause? Select ONE best answer.
- Run controlled success and failure commands, display or capture $?, inspect && and || order, and observe which branch actually executes.
- Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Feed literal backslashes and spaced lines through a test input, compare the resulting strings, and inspect whether a pipeline created a subshell.
Explanation
Correct Answer
B:Most direct verification evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory.
Incorrect Answers
A:That option would run controlled success and failure commands, display or capture $?, inspect && and || order, and observe which branch actually executes, but it addresses a different concern. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
C:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
D:This alternative addresses Reading input line by line and preserving backslashes, not the specific issue of Quoting expansions in file-processing loops: Feed literal backslashes and spaced lines through a test input, compare the resulting strings, and inspect whether a pipeline created a subshell. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Question 64
On a production Linux workstation or server, a technician observes: A nightly script iterates over filenames with spaces using for f in $(ls) and silently splits one filename into multiple arguments. Which observed outcome BEST confirms a successful and properly scoped correction? Select ONE best answer.
- Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
- Required settings persist in the invoking shell and decommissioned variables no longer remain defined or exported into new children.
- The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
Explanation
Correct Answer
A:Observable acceptance criterion: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Incorrect Answers
B:This alternative addresses Sourcing shell settings and removing variables, not the specific issue of Quoting expansions in file-processing loops: Required settings persist in the invoking shell and decommissioned variables no longer remain defined or exported into new children. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
C:This alternative addresses Command substitution tests and numeric conditions, not the specific issue of Quoting expansions in file-processing loops: 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: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. It cannot establish a safe correction. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
Question 65
During an LPIC-1 practice lab, the operator encounters this condition: A nightly script iterates over filenames with spaces using for f in $(ls) and silently splits one filename into multiple arguments. Which misleading assumption MOST directly contributes to this failure and should be rejected? Select ONE best answer.
- Edit the current administrator's ~/.bashrc and assume the account-creation utility automatically copies that live home directory to every new user.
- Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Insert the current directory before /usr/bin for convenience and assume any variable exported by a finished child script alters the parent shell.
Explanation
Correct Answer
C:Reject this specific misconception: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. It incorrectly assumes behavior that conflicts with the observed Linux conditions.
Incorrect Answers
A:This alternative addresses Account skeleton directory and default dotfiles, not the specific issue of Quoting expansions in file-processing loops: Edit the current administrator's ~/.bashrc and assume the account-creation utility automatically copies that live home directory to every new user. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
B: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. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
D:This alternative addresses Safe PATH changes and environment export, not the specific issue of Quoting expansions in file-processing loops: Insert the current directory before /usr/bin for convenience and assume any variable exported by a finished child script alters the parent shell. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Question 66
A helpdesk escalation describes this Linux behavior: A cleanup script runs rm $target on an untrusted path containing whitespace and wildcard characters, deleting files the operator did not intend. Which administrative step is the MOST appropriate way to resolve this issue? Select ONE best answer.
- 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.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate.
- Export only required variables and construct a deliberately ordered PATH using trusted absolute directories; source a file when the current shell must receive its changes.
Explanation
Correct Answer
C:Recommended administrative action: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate.
Incorrect Answers
A: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. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
B:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. It cannot establish a safe correction. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
D:This alternative addresses Safe PATH changes and environment export, not the specific issue of Quoting expansions in file-processing loops: Export only required variables and construct a deliberately ordered PATH using trusted absolute directories; source a file when the current shell must receive its changes. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Question 67
An operations handoff identifies this problem: A cleanup script runs rm $target on an untrusted path containing whitespace and wildcard characters, deleting files the operator did not intend. Which Linux behavior or technical principle BEST explains why the issue occurs? Select ONE best answer.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
- 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.
- read -r avoids backslash escape processing, an empty IFS can preserve leading and trailing whitespace, and shell pipeline subshells may isolate assignments.
Explanation
Correct Answer
B:Relevant Linux operating principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
Incorrect Answers
A:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
C:This alternative addresses Safe PATH changes and environment export, not the specific issue of Quoting expansions in file-processing loops: 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: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
D:This alternative addresses Reading input line by line and preserving backslashes, not the specific issue of Quoting expansions in file-processing loops: read -r avoids backslash escape processing, an empty IFS can preserve leading and trailing whitespace, and shell pipeline subshells may isolate assignments. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Question 68
A team maintaining a Linux host reports: A cleanup script runs rm $target on an untrusted path containing whitespace and wildcard characters, deleting files the operator did not intend. Which evidence or command result MOST directly tests the suspected root cause? Select ONE best answer.
- Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory.
- Inspect /etc/skel permissions and contents, review useradd home-creation settings, then create a controlled test account and compare its new home.
- Compare shell variables before and after sourcing, inspect the variable with parameter expansion or env, and confirm unset changes definedness as intended.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
Explanation
Correct Answer
A:Most direct verification evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory.
Incorrect Answers
B: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. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
C:That option would compare shell variables before and after sourcing, inspect the variable with parameter expansion or env, and confirm unset changes definedness as intended, but it addresses a different concern. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
D:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. It cannot establish a safe correction. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
Question 69
While verifying a Linux change request, an engineer finds: A cleanup script runs rm $target on an untrusted path containing whitespace and wildcard characters, deleting files the operator did not intend. Which observed outcome BEST confirms a successful and properly scoped correction? Select ONE best answer.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Fresh shells of each intended type obtain the expected settings without introducing duplicate PATH entries or leaking secrets.
- The success path executes only after a zero exit status and the failure notification executes only for intended errors.
- Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Explanation
Correct Answer
D:Observable acceptance criterion: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Incorrect Answers
A:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
B:This alternative addresses Bash login and interactive startup files, not the specific issue of Quoting expansions in file-processing loops: Fresh shells of each intended type obtain the expected settings without introducing duplicate PATH entries or leaking secrets. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
C:This alternative addresses Shell exit status and AND OR command lists, not the specific issue of Quoting expansions in file-processing loops: The success path executes only after a zero exit status and the failure notification executes only for intended errors. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.
Question 70
A Linux administrator investigates the following system incident: A cleanup script runs rm $target on an untrusted path containing whitespace and wildcard characters, deleting files the operator did not intend. Which TWO complementary steps provide the best corrective action and its most direct diagnostic verification? Select TWO answers.
- Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory.
- Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate.
- 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.
- Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
- Use source or the dot command to evaluate trusted configuration in the current shell, and use unset to remove the variable or function definition when required.
Explanation
Correct Answers
A:Most direct verification evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
B:Recommended administrative action: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
Incorrect Answers
C: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. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
D:This shortcut is unsafe for the present Linux issue: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters.
E:This alternative addresses Sourcing shell settings and removing variables, not the specific issue of Quoting expansions in file-processing loops: Use source or the dot command to evaluate trusted configuration in the current shell, and use unset to remove the variable or function definition when required. Linux principle: Unquoted expansions undergo field splitting and pathname expansion; command output is not a safe universal list of filenames containing arbitrary characters. Appropriate response: Use safe quoting of parameter expansions and handle filename iteration without parsing ls output, using robust globbing or null-delimited input where appropriate. Root-cause evidence: Test against filenames with spaces and glob characters, inspect quoted expansions and use a shell-safe enumeration in a throwaway directory. Independent acceptance: Each intended file is processed exactly once with its literal name preserved and no unintended neighbor files are changed.