nerdexam
CompTIA

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.

GNU and Unix Commands

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)
  • A
    6% (1)
  • B
    6% (1)
  • E
    89% (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.

Asource /usr/local/bin/runme.sh

'source' is a valid bash built-in that reads and executes the script within the current shell environment.

B. /usr/local/bin/runme.sh

The dot (.) command is a POSIX-standard shell built-in equivalent to 'source' and executes the script in the current shell.

C/bin/bash /usr/local/bin/runme.sh

Invoking /bin/bash with the script path is a valid method that explicitly uses the Bash interpreter to run the script.

D/usr/local/bin/runme.sh

Providing the full absolute path executes the script directly using the interpreter defined in its shebang line, provided the file has execute permission set.

Erun /usr/local/bin/runme.shCorrect

'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

#bash scripts#script execution#source command

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice