Bird
0
0

A script starts with #!/bin/bash but running ./script.sh gives bad interpreter: No such file or directory. What is the problem?

medium📝 Debug Q7 of 15
Bash Scripting - Basics
A script starts with #!/bin/bash but running ./script.sh gives bad interpreter: No such file or directory. What is the problem?
AThe path /bin/bash does not exist on the system
BThe script is missing execute permission
CThe script file is empty
DThe script has Windows line endings
Step-by-Step Solution
Solution:
  1. Step 1: Understand bad interpreter error

    This error often occurs if the shebang line has wrong line endings.
  2. Step 2: Recognize Windows line endings cause this

    Windows uses CRLF endings, which confuse Linux interpreters.
  3. Final Answer:

    The script has Windows line endings -> Option D
  4. Quick Check:

    Bad interpreter error often means wrong line endings [OK]
Quick Trick: Convert script to Unix line endings to fix bad interpreter error [OK]
Common Mistakes:
MISTAKES
  • Assuming /bin/bash is missing (rare on Linux)
  • Ignoring line ending differences
  • Not checking file permissions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes