Home › Linux & shell

bash: ./script.sh: Permission denied — how to fix

bash: ./script.sh: Permission denied

Quick fix: Run chmod +x script.sh and try ./script.sh again. Or run it without the execute bit: bash script.sh.

What it means

To run ./script.sh directly, the file needs the execute permission for your user. It doesn't have it.

Fix

chmod +x script.sh
./script.sh

Or skip the permission check by passing the file to the interpreter:

bash script.sh
python3 script.py

Check the permissions

ls -l script.sh
# -rw-r--r--  → not executable
# -rwxr-xr-x  → executable

Still "Permission denied" after chmod +x

The filesystem is mounted noexec. Common for /tmp, USB drives, and some shared folders:

findmnt -T script.sh -o TARGET,OPTIONS

If you see noexec, move the script elsewhere (e.g. your home folder) or run it with bash script.sh.

The file belongs to someone else and only they have execute rights. Check the owner in ls -l, and fix with sudo chown "$USER" script.sh if appropriate.

A folder in the path isn't searchable (missing x on a directory). Check with namei -l /path/to/script.sh.

In Git, the execute bit is tracked. Commit it so others get it too:

git update-index --chmod=+x script.sh
git commit -m "Make script executable"

"Permission denied" for other commands

If the message comes from inside the script (e.g. writing a file in /etc), the script needs higher privileges for that step: run it with sudo, or change the target path.

Last updated 2026-10-27.