Skip to main content
linuxbeginnerpermissionsVerified

Linux Permission Denied: Causes and Fixes

Last reviewed: 9/14/2026
3 solutions

Exact Error Message

Permission denied or bash: script.sh: Permission denied

Quick 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
  1. 1Check file permissions: ls -la filename
  2. 2Check current user: whoami
  3. 3Check group membership: groups
  4. 4Verify directory permissions
  5. 5Check for SELinux contexts: ls -Z

Solutions

Solution 1: Add execute permission
  1. 1Check current permissions
  2. 2Add execute permission to file
  3. 3Verify permission change
  4. 4Try executing the file again

Commands to Run

Execute permissions should be granted carefully for security

ls -la script.sh
chmod +x script.sh
ls -la script.sh
./script.sh
Solution 2: Change file ownership
  1. 1Identify correct owner and group
  2. 2Change ownership using chown
  3. 3Verify ownership change
  4. 4Test access

Commands to Run

Changing ownership can affect other users and processes

sudo chown user:group filename
sudo chown -R user:group directory/
Solution 3: Use sudo for administrative tasks
  1. 1Verify the command requires root privileges
  2. 2Use sudo to execute with elevated permissions
  3. 3Consider adding user to sudoers for persistent access
  4. 4Use sudo with caution

Commands to Run

sudo grants full system access - use carefully

sudo command

Avoid running applications as root when possible

sudo -i for root shell
Prevention 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.)

Was this helpful?