chmod Permission Denied on Script — Making Shell Scripts Executable on Linux
Informationalpermissions
Overview
Fix permission errors when trying to run or chmod shell scripts on Linux, including execute permission, shebang lines, and filesystem restrictions.
Key Details
- Shell scripts require execute (x) permission to run directly: chmod +x script.sh
- The shebang line (#!/bin/bash) tells the kernel which interpreter to use for the script
- Scripts on FAT32, NTFS, or noexec-mounted filesystems cannot be made executable
- Even root cannot set execute permission on noexec filesystems
- Scripts can always be run via the interpreter directly: bash script.sh (bypasses execute permission)
Common Causes
- Script does not have execute permission (missing chmod +x after creation)
- Script on a FAT32/NTFS partition that does not support Unix permissions
- Filesystem mounted with noexec option preventing execution of any scripts/binaries
- Script has Windows-style line endings (CRLF) causing the shebang to fail
Steps
- 1Add execute permission: 'chmod +x script.sh' then run with './script.sh'
- 2If chmod fails on FAT/NTFS: run the script via interpreter directly: 'bash script.sh'
- 3Check filesystem mount options: 'mount | grep noexec' — remount without noexec if appropriate
- 4Fix line endings: 'dos2unix script.sh' or 'sed -i "s/\r//" script.sh' for Windows-created scripts
- 5Verify shebang: first line should be #!/bin/bash or #!/usr/bin/env bash (with no leading spaces)
Tags
chmodpermissionsscriptexecuteshebang
More in Permissions
mac-error-4302-screencaptureMac Error 4302 — Screen Recording & Capture Permission Error
Warningmac-full-disk-access-permission-errorsMac Full Disk Access Errors — Permission Denied for Apps and Terminal
Warninglinux-permission-denied-chmod-chownLinux Permission Denied — chmod, chown & ACL Troubleshooting Guide
Warningbrowser-permission-api-errorsBrowser Permission API Errors — Notification, Geolocation & Camera Denied
Informationalbrowser-notification-permission-errorsWeb Notification Errors — Permission Denied and Push Notification Failures
Informationalbrowser-geolocation-errorsBrowser Geolocation Errors — Permission Denied and Position Unavailable
WarningFrequently Asked Questions
'bash script.sh' launches bash and tells it to read the file as input — no execute permission needed on the file. './script.sh' asks the kernel to execute the file directly, which requires the execute permission bit to be set.