ErrorLinux
bash: permission denied
Why bash refuses to run a script with Permission denied, how a missing execute bit differs from a noexec mount, and the safe ways to fix either.
Last updated
ErrorLinux
bash: ./script.sh: Permission denied
What it means: The shell found the file and tried to execute it directly, but the filesystem's permission bits don't allow your user to run it.
Likely causes
Most probable first — with how to confirm.
- 1.The file lacks the execute bit — check with `ls -l script.sh`; if the permissions string has no `x` (e.g. `-rw-r--r--`), that's the cause.
- 2.You're running it as `./script.sh` (direct execution, which needs the execute bit) rather than `bash script.sh` (which only needs read access, since bash itself reads and interprets the file).
- 3.The file lives on a filesystem mounted without exec permission — some network shares, or a Windows drive mounted into WSL, can be mounted `noexec` — check with `mount | grep noexec` for the relevant mount point.
- 4.You own the file, but the containing directory restricts traversal for your user, or the file is owned by another user or group without execute rights granted to you — check `ls -ld` on the directory too.
Fixes
Safest first; destructive ones are called out.
- →Add the execute bit: `chmod +x script.sh`, then re-run `./script.sh` — the standard fix, and non-destructive.
- →If you'd rather not change permissions, run it through the interpreter directly: `bash script.sh` or `sh script.sh`, which only needs read access.
- →If the file lives on a `noexec`-mounted filesystem, copy it to a location that allows execution (like your home directory) instead of trying to force exec rights on that mount.
- →Confirm this isn't actually 'command not found' — permission denied means the file was found; a missing file or a path problem produces a different error instead.