LX0-103 · Question #188
All of the following commands will execute the bash script /usr/local/bin/runme.sh EXCEPT:
The correct answer is E. run /usr/local/bin/runme.sh. 'run' is not a standard Linux command, so 'run /usr/local/bin/runme.sh' will fail with a command-not-found error while all other options are valid execution methods.
Question
All of the following commands will execute the bash script /usr/local/bin/runme.sh EXCEPT:
Options
- Asource /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
- Erun /usr/local/bin/runme.sh
How the community answered
(18 responses)- A6% (1)
- B6% (1)
- E89% (16)
Why each option
'run' is not a standard Linux command, so 'run /usr/local/bin/runme.sh' will fail with a command-not-found error while all other options are valid execution methods.
'source' is a valid bash built-in that reads and executes the script within the current shell environment.
The dot (.) command is a POSIX-standard shell built-in equivalent to 'source' and executes the script in the current shell.
Invoking /bin/bash with the script path is a valid method that explicitly uses the Bash interpreter to run the script.
Providing the full absolute path executes the script directly using the interpreter defined in its shebang line, provided the file has execute permission set.
'run' does not exist as a standard Linux or Unix utility - it is not part of any common shell, coreutils, or distribution package, so invoking it will result in a 'command not found' error. All other listed options are legitimate: source and . execute in the current shell, /bin/bash explicitly calls the interpreter, and a direct path executes via the script's shebang line.
Concept tested: Linux shell script execution methods compared
Source: https://www.gnu.org/software/bash/manual/bash.html#Shell-Scripts
Topics
Community Discussion
No community discussion yet for this question.