zsh: permission denied: ./script.sh
You’re trying to run a file that doesn’t have execute permission.
Fix 1: Add Execute Permission
chmod +x ./script.sh
./script.sh
That’s it for 90% of cases. The file exists but isn’t marked as executable.
Fix 2: Run With the Interpreter Directly
If you can’t change permissions (read-only filesystem, etc.):
bash ./script.sh
python3 ./script.py
node ./app.js
This bypasses the execute permission check because you’re running bash/python3/node (which IS executable), and passing the file as an argument.
Fix 3: Downloaded Script from the Internet
macOS quarantines downloaded files. Even with chmod +x, you might get blocked.
# Remove quarantine attribute
xattr -d com.apple.quarantine ./script.sh
# Then make executable
chmod +x ./script.sh
Fix 4: Trying to Run a Directory
# ❌ This is a directory, not a file
./my-project
# ✅ You probably meant
cd ./my-project
Fix 5: Wrong Shebang Line
If the script has a shebang (#!) pointing to a non-existent interpreter:
#!/usr/local/bin/python # ❌ Python might not be here
#!/usr/bin/env python3 # ✅ Portable — finds python3 in PATH
#!/usr/bin/env bash # ✅ Portable — finds bash in PATH
Quick Diagnosis
# Check current permissions
ls -la ./script.sh
# -rw-r--r-- = no execute (missing x)
# -rwxr-xr-x = has execute
# Check file type
file ./script.sh