Interview Prep/Shell Scripting/Troubleshooting: syntax, parsing and interpreter errors

`bash: ./backup.sh: Permission denied` right after cloning the repo.

BeginnerTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer

Likely causes → The execute bit is not set, either locally or in Git (the file was committed with mode 100644).

Diagnose →

ls -l backup.sh                       # -rw-r--r--
git ls-files -s backup.sh             # 100644 = not executable in Git

Fix → chmod +x backup.sh locally, and record it in Git: git update-index --chmod=+x backup.sh && git commit -m "make backup.sh executable". As a workaround, bash backup.sh runs it without the bit.

Prevent → Commit scripts with mode 100755, and add a CI check: git ls-files -s '*.sh' | awk '$1 != "100755" {print "not executable:", $4; bad=1} END {exit bad}'.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: syntax, parsing and interpreter errors