nerdexam
LPI

010-160 · Question #95

Which of the following statements are true regarding a typical shell script? (Choose two.)

The correct answer is A. It has the executable permission bit set. A shell script must have the executable permission bit set so the operating system will permit it to run directly as a program.

The Power of the Command Line

Question

Which of the following statements are true regarding a typical shell script? (Choose two.)

Options

  • AIt has the executable permission bit set.
  • BIt starts with the two character sequence #!.
  • CIt is located in /usr/local/scripts/.
  • DIt is located in /etc/bash/scripts/.
  • EIt is compiled into a binary file compatible with the current machine architecture.

How the community answered

(47 responses)
  • A
    91% (43)
  • B
    2% (1)
  • C
    4% (2)
  • E
    2% (1)

Why each option

A shell script must have the executable permission bit set so the operating system will permit it to run directly as a program.

AIt has the executable permission bit set.Correct

For a shell script to be executed directly (e.g., './script.sh'), the filesystem executable permission bit must be set via chmod. Without it, the kernel returns a permission denied error and refuses to run the file.

BIt starts with the two character sequence #!.

While the shebang (#!) is a widely used convention specifying the interpreter, it is not strictly required - a script can be run by passing it directly to the interpreter (e.g., bash script.sh) without one.

CIt is located in /usr/local/scripts/.

Shell scripts can reside in any directory accessible to the user; no Linux standard mandates placement in /usr/local/scripts/.

DIt is located in /etc/bash/scripts/.

There is no standard /etc/bash/scripts/ directory defined by the Linux Filesystem Hierarchy Standard for shell scripts.

EIt is compiled into a binary file compatible with the current machine architecture.

Shell scripts are interpreted text files executed by a shell at runtime and are never compiled into machine-code binaries.

Concept tested: Shell script execution requirements and file permissions

Source: https://www.gnu.org/software/bash/manual/bash.html#Executing-Commands

Topics

#shell scripts#shebang#executable permissions#script structure

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice