LPIC-1 Exam 101 (Linux Administrator) — Question 8
From a Bash shell, which of the following commands directly executes the instruction from the file /usr/local/bin/runme.sh without starting a subshell? (Please select TWO answers.)
Answer options
- A. source /usr/local/bin/runme.sh
- B. . /usr/local/bin/runme.sh
- C. /bin/bash /usr/local/bin/runme.sh
- D. /usr/local/bin/runme.sh
- E. run /usr/local/bin/runme.sh
Correct answer: A, B
Explanation
The commands 'source /usr/local/bin/runme.sh' and '. /usr/local/bin/runme.sh' both execute the script in the current shell context, allowing any variables or functions defined in the script to be available afterwards. In contrast, executing the script with '/bin/bash /usr/local/bin/runme.sh' or '/usr/local/bin/runme.sh' starts a new subshell, and 'run /usr/local/bin/runme.sh' is not a valid command for executing the script.