nerdexam
Linux_Foundation

LFCS · Question #92

Which of the following are requirements in order to run a shell script like a regular command from anywhere in the filesystem? (Choose THREE correct answers.)

The correct answer is B. The script file must be found in the $PATH. C. The script file must have the executable permission bit set. D. The script must begin with a shebang-line (#!) that points to the correct interpreter. To execute a shell script as a regular command from any location, it must be located within the system's $PATH, have executable permissions, and specify its interpreter with a shebang line.

Submitted by parkjh· Apr 18, 2026Essential Commands

Question

Which of the following are requirements in order to run a shell script like a regular command from anywhere in the filesystem? (Choose THREE correct answers.)

Options

  • AThe user issuing the command must be in the group script.
  • BThe script file must be found in the $PATH.
  • CThe script file must have the executable permission bit set.
  • DThe script must begin with a shebang-line (#!) that points to the correct interpreter.
  • EThe file system on which the script resides must be mounted with the option scripts.

How the community answered

(47 responses)
  • A
    4% (2)
  • B
    94% (44)
  • E
    2% (1)

Why each option

To execute a shell script as a regular command from any location, it must be located within the system's `$PATH`, have executable permissions, and specify its interpreter with a shebang line.

AThe user issuing the command must be in the group script.

There is no standard requirement for a user to be in a specific group named "script" to execute a shell script.

BThe script file must be found in the $PATH.Correct

For a script to be run by simply typing its name without a full path from any directory, its directory must be included in the user's `$PATH` environment variable, which the shell searches for commands.

CThe script file must have the executable permission bit set.Correct

Executable permissions (e.g., `chmod +x script.sh`) are essential for the operating system to allow a script to be run directly by the user, indicating it is an executable program.

DThe script must begin with a shebang-line (#!) that points to the correct interpreter.Correct

The shebang line `#!` at the beginning of a script specifies the interpreter (e.g., `#!/bin/bash`) that should be used to execute the script, allowing the system to run it correctly without explicitly calling the interpreter.

EThe file system on which the script resides must be mounted with the option scripts.

Filesystems are not typically mounted with an "scripts" option; executable permissions and the `$PATH` variable handle script execution, not a mount option.

Concept tested: Shell script execution requirements

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Invoking-Shell-Scripts

Topics

#Shell scripting#File permissions#PATH variable#Shebang

Community Discussion

No community discussion yet for this question.

Full LFCS Practice