Type the first line a script must contain so that the kernel runs it with the Bourne Again shell installed at /bin/bash.

LPIC-1 Exam 102-500, objective 105. Shells and shell scripting easy

Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.

It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.

Answer

Type the answer.

Accepted answers

Case sensitive — Linux is, and grading LS as ls would teach a falsehood.

Why

The shebang is the two characters #! at the very start of the file, followed by the absolute path to the interpreter. The kernel reads it when the file is executed and starts that interpreter with the script as an argument. A relative path is resolved against the current working directory, so it is unreliable and effectively always wrong here, and the #! must be the first two bytes of the file, so a blank line or a comment before it disables the mechanism and the calling shell decides the interpreter instead. `#!/bin/sh` selects the POSIX shell instead, which on Debian-family systems is dash and rejects bash-only syntax such as [[ ]] and arrays.

Where this comes from

Cited
LPI exam objective 105.2
What it says
Give a script the correct interpreter line.

Practise this

Reading one question is not practice. The trainer will draw a set from objective 105 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500