A bootstrap step `curl -fsSL "$URL" -o /tmp/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh` fails with `bash: /tmp/install.sh: Permission denied`, despite the `chmod`.
IntermediateTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → /tmp is mounted with noexec (CIS hardening benchmarks require it), so the kernel refuses to execute any file there regardless of its mode.
Diagnose →
findmnt -no OPTIONS /tmp # rw,nosuid,nodev,noexec,...
ls -l /tmp/install.sh # mode is fine
Fix → Run it through the interpreter, or download to a location meant for executables after verifying it:
bash /tmp/install.sh # the file is read, not executed
echo "${EXPECTED_SHA256} /tmp/install.sh" | sha256sum -c -
Prevent → Do not depend on executing from /tmp; verify checksums of anything downloaded before running it, and test bootstrap scripts on hardened images.
More on Troubleshooting: tools, portability, permissions and environment
On a Mac, `sed -i 's/replicas: 2/replicas: 3/' deploy.yaml` fails with `sed: 1: "deploy.yaml": extra characters at the end of d command`.BeginnerA cleanup script fails on a developer's Mac with `date: illegal option -- d`.BeginnerA script that works on Ubuntu fails in an Alpine-based CI image with `grep: unrecognized option: P`.IntermediateAn `awk` one-liner works on your RHEL box but fails on Ubuntu with `awk: line 1: function gensub never defined`.Intermediate`comm -23 expected.txt installed.txt` prints `comm: file 1 is not in sorted order`, even though both files were produced with `sort`.Intermediate`grep ERROR /var/log/app/app.log` prints only `grep: /var/log/app/app.log: binary file matches`.Beginner