linuxbeginnerpermissionsVerified
Linux Permission Denied: Causes and Fixes
Last reviewed: 9/14/2026
3 solutions
Exact Error Message
Permission denied or bash: script.sh: Permission deniedQuick Fix
Add execute permission: chmod +x script.sh or run with sudo if appropriate.
What This Error Means
Permission denied errors occur when Linux file system permissions prevent a user from performing an action. This is controlled by read, write, and execute permissions for owner, group, and others.
Common Symptoms
- •Cannot execute scripts
- •Cannot access files or directories
- •Cannot modify files
- •Installation or configuration failures
Common Causes
- •File lacks execute permission
- •User not in required group
- •Directory lacks execute permission
- •Ownership mismatch
- •SELinux/AppArmor restrictions
- •Root privilege required
Diagnostic Steps
- 1Check file permissions: ls -la filename
- 2Check current user: whoami
- 3Check group membership: groups
- 4Verify directory permissions
- 5Check for SELinux contexts: ls -Z
Solutions
Solution 1: Add execute permission
- 1Check current permissions
- 2Add execute permission to file
- 3Verify permission change
- 4Try executing the file again
Commands to Run
Execute permissions should be granted carefully for security
ls -la script.shchmod +x script.shls -la script.sh./script.shSolution 2: Change file ownership
- 1Identify correct owner and group
- 2Change ownership using chown
- 3Verify ownership change
- 4Test access
Commands to Run
Changing ownership can affect other users and processes
sudo chown user:group filenamesudo chown -R user:group directory/Solution 3: Use sudo for administrative tasks
- 1Verify the command requires root privileges
- 2Use sudo to execute with elevated permissions
- 3Consider adding user to sudoers for persistent access
- 4Use sudo with caution
Commands to Run
sudo grants full system access - use carefully
sudo commandAvoid running applications as root when possible
sudo -i for root shellPrevention Tips
- ✓Use principle of least privilege
- ✓Set appropriate umask for new files
- ✓Use groups for shared access
- ✓Document permission requirements
- ✓Regularly audit permissions
Version Notes: Applies to most Linux distributions (Ubuntu, CentOS, Debian, etc.)
Official Documentation
Related Errors
GitHub Actions Permission Denied: Causes and Fixes
GitHub Actions workflow fails due to insufficient permissions or authentication issues.
Docker Permission Denied: Causes and Fixes
User cannot access Docker daemon socket due to insufficient permissions.
AWS S3 Access Denied: Causes and Fixes
AWS S3 denies access to bucket or object due to insufficient permissions.
Linux No Space Left on Device: Causes and Fixes
Linux disk is full and cannot write new files or perform operations.
Was this helpful?