Bird
0
0

You set execute permission on run.sh using chmod +x run.sh but still get 'Permission denied' when running ./run.sh. What could be the cause?

medium📝 Debug Q6 of 15
Bash Scripting - Basics
You set execute permission on run.sh using chmod +x run.sh but still get 'Permission denied' when running ./run.sh. What could be the cause?
AThe script has a syntax error.
BThe script file is empty.
CThe directory containing <code>run.sh</code> lacks execute permission.
DThe file system is read-only.
Step-by-Step Solution
Solution:
  1. Step 1: Check file execute permission

    chmod +x sets execute permission on the file itself.
  2. Step 2: Directory execute permission

    To run ./run.sh, the directory must have execute permission to allow traversal.
  3. Step 3: Analyze options

    The directory containing run.sh lacks execute permission. correctly identifies missing directory execute permission as cause.
    The script file is empty. (empty file) does not cause permission denied.
    The script has a syntax error. (syntax error) causes runtime errors, not permission denied.
    The file system is read-only. (read-only) may prevent writing but not execution if permissions allow.
  4. Final Answer:

    The directory containing run.sh lacks execute permission. -> Option C
  5. Quick Check:

    Is directory executable? If no, permission denied occurs [OK]
Quick Trick: Directory needs execute permission to run scripts [OK]
Common Mistakes:
MISTAKES
  • Assuming file execute permission is enough
  • Confusing syntax errors with permission issues

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes