Error Codes Wiki

Linux Permission Denied — Cannot Execute Script Fix

Informationallinux command

About Linux Permission Denied

Fix "Permission denied" when trying to run a script on Linux. The file lacks execute permission. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: Error: Permission denied (when executing). Category: Linux Command Error. Script/binary lacks execute permission. Cannot run the file. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: File does not have execute (+x) permission. File downloaded from internet lost execute bit. File system mounted with noexec option. SELinux or AppArmor blocking execution. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Add execute permission: chmod +x script.sh. Run with interpreter: bash script.sh (bypasses execute bit). Check mount options: mount | grep noexec. Check SELinux: sestatus and audit log. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Why do downloaded scripts lose +x?

Browsers and file transfers often strip execute permissions for security.

Overview

Fix "Permission denied" when trying to run a script on Linux. The file lacks execute permission.

Key Details

  • Error: Permission denied (when executing)
  • Category: Linux Command Error
  • Script/binary lacks execute permission
  • Cannot run the file

Common Causes

  • File does not have execute (+x) permission
  • File downloaded from internet lost execute bit
  • File system mounted with noexec option
  • SELinux or AppArmor blocking execution

Steps

  1. 1Add execute permission: chmod +x script.sh
  2. 2Run with interpreter: bash script.sh (bypasses execute bit)
  3. 3Check mount options: mount | grep noexec
  4. 4Check SELinux: sestatus and audit log

Tags

linuxlinux-commandlinux permission denied execubuntuterminal

More in Linux Command

Frequently Asked Questions

Browsers and file transfers often strip execute permissions for security.