nerdexam
LPI

102-400 · Question #101

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. See the full explanation below for the reasoning.

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

(34 responses)
  • A
    15% (5)
  • B
    79% (27)
  • E
    6% (2)

Community Discussion

5
Viktor S.Viktor S.Jun 27, 2026

B, C, and D are your three. The shell needs to find the file, so it has to live somewhere on your PATH, full stop. Once the shell finds it, the kernel checks the execute bit before it will run anything as a program, so without that permission nothing happens regardless of content. The shebang line tells the kernel which interpreter to hand the script off to, whether that is bash or python or anything else, because the kernel does not just guess. A and E are distractors that sound plausible to people who have not actually thought about how execve works, but there is no "script" group and no "scripts" mount option in any real Linux system.

23
Nina C.Nina C.Jun 29, 2026

One thing worth adding for the exam is that PATH only matters when you type just the bare script name, because if you run it as ./script.sh or give the full path like /home/user/script.sh, the shell finds it just fine without PATH being involved at all.

0
Ola B.Ola B.Jun 20, 2026

I kept second-guessing myself on A because I half-remembered some permission model details from studying, but then I spun up a quick VM and just tried it, created a script owned by root with no group magic at all, dropped it in /usr/local/bin, chmod +x it, added the shebang, and ran it as a regular user no problem. That confirmed it right there, B, C, and D are the three you need, the file has to be in your PATH so the shell can find it, executable bit has to be set so the OS will actually run it, and the shebang tells the kernel which interpreter to hand it off to.

2
Nina C.Nina C.Jun 14, 2026

Had to be A, group access controls who can run it.

-2
Ola B.Ola B.Jun 16, 2026

Actually Nina, it is B, C, and D on this one. Group membership controls access, but the question is asking about the mechanisms that enforce or configure the behavior itself, and those three options cover the actual policy, logging, and execution settings that make it work end to end.

0
Full 102-400 Practice