CalcSnippets Search
CLI 2 min read

`chmod +x` Is the Fix When a Script Looks Correct but Your Shell Keeps Saying Permission Denied Like It Enjoys Wasting Your Time

A practical guide to `chmod +x` for making shell scripts and local tools executable when the file contents are fine but the execute bit is missing.

Why this command matters: sometimes the file is fine, the code is fine, and the only thing broken is that the operating system is refusing to run it on permission grounds.

If you try to run a script like ./deploy.sh and get:

Permission denied

one common reason is simply that the file is not marked executable.

The fix

chmod +x deploy.sh

Now you can run:

./deploy.sh

This adds the execute bit to the file’s mode so the shell can launch it directly.

Why this shows up so often

Common reasons include:

  1. the file was copied from a system that lost mode bits
  2. a new script was created without executable permissions
  3. a repo did not preserve the intended mode
  4. a generated helper script was written as plain text only

Developers often debug the script contents first when the system was never willing to execute the file at all.

Verify what the file mode is

ls -l deploy.sh

If you do not see execute bits in the mode string, that explains the denial.

After the fix, the mode may look more like:

-rwxr-xr-x

That means the file is executable for the owner and readable/executable for group and others.

Important nuance

chmod +x fixes executability, not script correctness. If the script still fails afterward, the next layers to check are:

  1. the shebang line, such as #!/bin/bash
  2. line endings if the file came from Windows
  3. referenced binaries and paths

But you should not debug any of that until the file is actually allowed to run.

Final recommendation

When a script looks fine but the shell says Permission denied, check the execute bit before you do anything smarter. chmod +x is one of the smallest fixes in development work and one of the most commonly overlooked.

Sources

Keep reading

Related guides