Courseiva
Shells, Scripting and Data ManagementmediumMultiple SelectObjective-mapped

LPIC-1 Shells, Scripting and Data Management Practice Question

Which TWO of the following are required for a bash script to be executed by the shell (assuming the script is in the current directory)?

⚠ Common exam trap

LPI often tests the misconception that a .sh extension is required for shell scripts, but Linux/Unix systems determine executability via the shebang and execute permission, not file extensions.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The script must have a shebang (#!) as the first line.

The shebang (#!) as the first line of a bash script tells the kernel which interpreter to use (e.g., #!/bin/bash). Without it, the shell may attempt to execute the script using the default shell (often /bin/sh), which can lead to syntax errors or unexpected behavior. The shebang is essential for explicitly specifying the interpreter, especially when the script uses bash-specific features.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The script must have a shebang (#!) as the first line.

    Why this is correct

    Required to specify interpreter.

  • The script must not contain any comments.

    Why it's wrong here

    Comments are allowed.

  • The script must have a .sh extension.

    Why it's wrong here

    Extension is not required.

  • The script must be in the PATH environment variable.

    Why it's wrong here

    It can be run with ./ if not in PATH.

  • The script must have execute permission.

    Why this is correct

    Without execute permission, the script cannot be run directly.

About these practice questions

Courseiva writes every LPIC-1 question from scratch — 527 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LPIC-1 practice question is part of Courseiva's free LPI certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LPIC-1 exam.