cert
cert-1
cert-2

Pass LPI 102-500 Exam in First Attempt Guaranteed!

Get 100% Latest Exam Questions, Accurate & Verified Answers to Pass the Actual Exam!
30 Days Free Updates, Instant Download!

cert-5
cert-6
102-500 Exam - Verified By Experts
102-500 Premium Bundle
$29.98

102-500 Premium Bundle

$79.99
$109.97
  • Premium File 120 Questions & Answers. Last update: Nov 13, 2026
  • Training Course 126 Video Lectures
  • Study Guide 962 Pages
 
$109.97
$79.99
accept 15 downloads in last 7 days
block-screenshots
Purchase LPI 102-500 Exam Training Products Individually
LPI 102-500 Premium File
Premium File 120 Q&A
$76.99$69.99
LPI 102-500 Video Training Course
Training Course 126 Lectures
$21.99 $19.99
LPI 102-500 PDF Study Guide
Study Guide 962 Pages
$21.99 $19.99
LPI 102-500 Practice Test 3

Question 20

While verifying a Linux change request, an engineer finds: A script exports a new variable in a child shell, yet the parent interactive session cannot see the change after that script exits. Which TWO complementary steps provide the best corrective action and its most direct diagnostic verification? Select TWO answers.

  1. Insert the current directory before /usr/bin for convenience and assume any variable exported by a finished child script alters the parent shell.
  2. 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.
  3. Use IFS= read -r within an appropriately redirected loop to preserve literal input and design variable state without relying on a pipeline subshell.
  4. Compare env and shell variable output, inspect PATH for empty or writable directories, and run type -a or command -v for the intended executables.
  5. 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

B:

Recommended administrative action: 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: 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.

D:

Most direct verification evidence: Compare env and shell variable output, inspect PATH for empty or writable directories, and run type -a or command -v for the intended executables. Linux principle: 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.

Incorrect Answers

A:

This shortcut is unsafe for the present Linux issue: Insert the current directory before /usr/bin for convenience and assume any variable exported by a finished child script alters the parent shell. 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.

C:

This alternative addresses Reading input line by line and preserving backslashes, not the specific issue of Safe PATH changes and environment export: Use IFS= read -r within an appropriately redirected loop to preserve literal input and design variable state without relying on a pipeline subshell.

E:

This alternative addresses Bash login and interactive startup files, not the specific issue of Safe PATH changes and environment export: 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.

Question 21

A Linux administrator investigates the following system incident: A helpdesk writes an alias expecting it to take a positional directory argument, but the alias does not support parameters like a function. Which administrative step is the MOST appropriate way to resolve this issue? Select ONE best answer.

  1. 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.
  2. 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.
  3. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
  4. Put login-specific exports in the appropriate user login profile and interactive aliases in ~/.bashrc, sourcing the interactive configuration from the login profile when desired.

Explanation

Correct Answer

B:

Recommended administrative action: 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. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Incorrect Answers

A:

This alternative addresses Sourcing shell settings and removing variables, not the specific issue of Bash functions versus aliases and command lookup: 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: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

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. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

D:

This alternative addresses Bash login and interactive startup files, not the specific issue of Bash functions versus aliases and command lookup: Put login-specific exports in the appropriate user login profile and interactive aliases in ~/.bashrc, sourcing the interactive configuration from the login profile when desired. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Question 22

On a production Linux workstation or server, a technician observes: A helpdesk writes an alias expecting it to take a positional directory argument, but the alias does not support parameters like a function. Which Linux behavior or technical principle BEST explains why the issue occurs? Select ONE best answer.

  1. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
  2. 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.
  3. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.
  4. 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

C:

Relevant Linux operating principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Incorrect Answers

A:

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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

B:

This alternative addresses Bash shebang and executable permission, not the specific issue of Bash functions versus aliases and command lookup: 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. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

D:

This alternative addresses Reading input line by line and preserving backslashes, not the specific issue of Bash functions versus aliases and command lookup: read -r avoids backslash escape processing, an empty IFS can preserve leading and trailing whitespace, and shell pipeline subshells may isolate assignments. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Question 23

During an LPIC-1 practice lab, the operator encounters this condition: A helpdesk writes an alias expecting it to take a positional directory argument, but the alias does not support parameters like a function. Which evidence or command result MOST directly tests the suspected root cause? Select ONE best answer.

  1. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
  2. Compare shell variables before and after sourcing, inspect the variable with parameter expansion or env, and confirm unset changes definedness as intended.
  3. 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.
  4. Inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation.

Explanation

Correct Answer

C:

Most direct verification evidence: 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. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Incorrect Answers

A:

This shortcut is unsafe for the present Linux issue: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

B:

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. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

D:

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. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Question 24

A helpdesk escalation describes this Linux behavior: A helpdesk writes an alias expecting it to take a positional directory argument, but the alias does not support parameters like a function. Which observed outcome BEST confirms a successful and properly scoped correction? Select ONE best answer.

  1. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
  2. Each input record retains intended characters and the final aggregation is available in the process where it is needed.
  3. The success path executes only after a zero exit status and the failure notification executes only for intended errors.
  4. Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Explanation

Correct Answer

D:

Observable acceptance criterion: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Incorrect Answers

A:

This shortcut is unsafe for the present Linux issue: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

B:

This alternative addresses Reading input line by line and preserving backslashes, not the specific issue of Bash functions versus aliases and command lookup: Each input record retains intended characters and the final aggregation is available in the process where it is needed. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

C:

This alternative addresses Shell exit status and AND OR command lists, not the specific issue of Bash functions versus aliases and command lookup: The success path executes only after a zero exit status and the failure notification executes only for intended errors. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Question 25

An operations handoff identifies this problem: A helpdesk writes an alias expecting it to take a positional directory argument, but the alias does not support parameters like a function. Which misleading assumption MOST directly contributes to this failure and should be rejected? Select ONE best answer.

  1. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
  2. Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters.
  3. Assume every Bash process automatically reads ~/.bashrc and ~/.bash_profile in the same order regardless of login and interactivity.
  4. Edit the current administrator's ~/.bashrc and assume the account-creation utility automatically copies that live home directory to every new user.

Explanation

Correct Answer

A:

Reject this specific misconception: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. It incorrectly assumes behavior that conflicts with the observed Linux conditions.

Incorrect Answers

B:

This alternative addresses Quoting expansions in file-processing loops, not the specific issue of Bash functions versus aliases and command lookup: Parse `ls` output with shell word splitting and remove files using unquoted variables because filenames never contain special characters. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

C:

That option would assume every Bash process automatically reads ~/.bashrc and ~/.bash_profile in the same order regardless of login and interactivity, but it addresses a different concern. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

D:

This alternative addresses Account skeleton directory and default dotfiles, not the specific issue of Bash functions versus aliases and command lookup: Edit the current administrator's ~/.bashrc and assume the account-creation utility automatically copies that live home directory to every new user. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Question 26

A team maintaining a Linux host reports: A troubleshooting script uses an alias defined in an interactive terminal and then fails when executed as a separate non-interactive Bash process. Which administrative step is the MOST appropriate way to resolve this issue? Select ONE best answer.

  1. Put login-specific exports in the appropriate user login profile and interactive aliases in ~/.bashrc, sourcing the interactive configuration from the login profile when desired.
  2. 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.
  3. Use IFS= read -r within an appropriately redirected loop to preserve literal input and design variable state without relying on a pipeline subshell.
  4. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.

Explanation

Correct Answer

B:

Recommended administrative action: 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.

Incorrect Answers

A:

This alternative addresses Bash login and interactive startup files, not the specific issue of Bash functions versus aliases and command lookup: Put login-specific exports in the appropriate user login profile and interactive aliases in ~/.bashrc, sourcing the interactive configuration from the login profile when desired. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

C:

That option would use IFS= read -r within an appropriately redirected loop to preserve literal input and design variable state without relying on a pipeline subshell, but it addresses a different concern. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

D:

This shortcut is unsafe for the present Linux issue: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Question 27

While verifying a Linux change request, an engineer finds: A troubleshooting script uses an alias defined in an interactive terminal and then fails when executed as a separate non-interactive Bash process. Which Linux behavior or technical principle BEST explains why the issue occurs? Select ONE best answer.

  1. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.
  2. 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.
  3. 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.
  4. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Explanation

Correct Answer

D:

Relevant Linux operating principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Incorrect Answers

A:

This shortcut is unsafe for the present Linux issue: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. It cannot establish a safe correction. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

B:

This alternative addresses Safe PATH changes and environment export, not the specific issue of Bash functions versus aliases and command lookup: 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: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

C:

This alternative addresses Shell exit status and AND OR command lists, not the specific issue of Bash functions versus aliases and command lookup: 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. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Question 28

A Linux administrator investigates the following system incident: A troubleshooting script uses an alias defined in an interactive terminal and then fails when executed as a separate non-interactive Bash process. Which evidence or command result MOST directly tests the suspected root cause? Select ONE best answer.

  1. Run controlled success and failure commands, display or capture $?, inspect && and || order, and observe which branch actually executes.
  2. 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.
  3. Compare shell variables before and after sourcing, inspect the variable with parameter expansion or env, and confirm unset changes definedness as intended.
  4. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.

Explanation

Correct Answer

B:

Most direct verification evidence: 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.

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. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

C:

This alternative addresses Sourcing shell settings and removing variables, not the specific issue of Bash functions versus aliases and command lookup: Compare shell variables before and after sourcing, inspect the variable with parameter expansion or env, and confirm unset changes definedness as intended.

D:

This shortcut is unsafe for the present Linux issue: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. It cannot establish a safe correction. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Question 29

On a production Linux workstation or server, a technician observes: A troubleshooting script uses an alias defined in an interactive terminal and then fails when executed as a separate non-interactive Bash process. Which observed outcome BEST confirms a successful and properly scoped correction? Select ONE best answer.

  1. A newly created test user receives the intended accessible default files with correct ownership, while existing homes remain unchanged unless explicitly migrated.
  2. The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step.
  3. Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.
  4. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.

Explanation

Correct Answer

C:

Observable acceptance criterion: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

Incorrect Answers

A:

This alternative addresses Account skeleton directory and default dotfiles, not the specific issue of Bash functions versus aliases and command lookup: A newly created test user receives the intended accessible default files with correct ownership, while existing homes remain unchanged unless explicitly migrated. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

B:

This alternative addresses Command substitution tests and numeric conditions, not the specific issue of Bash functions versus aliases and command lookup: The branch correctly distinguishes zero, positive and invalid input without running an unintended remediation step. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

D:

This shortcut is unsafe for the present Linux issue: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Question 30

During an LPIC-1 practice lab, the operator encounters this condition: A troubleshooting script uses an alias defined in an interactive terminal and then fails when executed as a separate non-interactive Bash process. Which TWO complementary steps provide the best corrective action and its most direct diagnostic verification? Select TWO answers.

  1. 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.
  2. 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.
  3. 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.
  4. Inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation.
  5. Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions.

Explanation

Correct Answers

A:

Recommended administrative action: 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. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

B:

Most direct verification evidence: 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. Linux principle: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

Incorrect Answers

C:

This alternative addresses Safe PATH changes and environment export, not the specific issue of Bash functions versus aliases and command lookup: 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: Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts. Appropriate response: 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. Root-cause evidence: 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. Independent acceptance: Parameterized helper calls behave correctly for supplied arguments and any script does not depend on an uninitialized interactive alias.

D:

This alternative addresses Bash shebang and executable permission, not the specific issue of Bash functions versus aliases and command lookup: Inspect the first line, file mode, file type and any shell syntax errors, then execute in a controlled test account using the expected invocation.

E:

This shortcut is unsafe for the present Linux issue: Treat an alias as an executable application that always accepts positional parameters in scripts without loading the relevant shell definitions. Functions accept positional parameters and are shell constructs; aliases are mainly parsed in interactive shells and are not a reliable portable interface for executable scripts.

LPI Level 1 (102-500) Practice Tests