nerdexam
CompTIA

LX0-104 · Question #555

An administrator is looking into a new script that they have just received from a senior administrator. In the very first line the administrator notices a #! followed by a path to a binary. Linux will

The correct answer is B. use that binary to interpret the script.. When a script begins with a #! (shebang) followed by a path to a binary, Linux uses that specified binary as the interpreter to execute the script's contents.

Shells, Scripting and Data Management

Question

An administrator is looking into a new script that they have just received from a senior administrator. In the very first line the administrator notices a #! followed by a path to a binary. Linux will:

Options

  • Aignore the script.
  • Buse that binary to interpret the script.
  • Cuse that binary to compile the script.
  • Dbe replaced by that binary.

How the community answered

(51 responses)
  • A
    4% (2)
  • B
    92% (47)
  • C
    2% (1)
  • D
    2% (1)

Why each option

When a script begins with a `#!` (shebang) followed by a path to a binary, Linux uses that specified binary as the interpreter to execute the script's contents.

Aignore the script.

The shebang line indicates the script is intended for execution, not to be ignored.

Buse that binary to interpret the script.Correct

The `#!` (shebang) sequence at the beginning of a script is a convention understood by the Linux kernel's program loader. When an executable script is invoked, the kernel reads the shebang line and uses the path specified after `#!` (e.g., `/bin/bash`, `/usr/bin/python`) to execute the script as an argument to that interpreter.

Cuse that binary to compile the script.

The binary specified by `#!` is typically an interpreter, not a compiler, meaning it executes the script directly rather than transforming it into machine code.

Dbe replaced by that binary.

The binary interprets the script; it does not replace the Linux operating system.

Concept tested: Shebang line script execution

Source: https://manpages.org/man/2/execve

Topics

#shebang#shell scripting#script execution

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice