Knowledge

How to make a script executable with chmod +x

#CommandLine

Fix the Permission denied error when running a shell script by adding the execute bit with chmod +x, plus the shebang line and chmod 755.

Published by Mark van Eijk on June 23, 2026 · 1 minute read

  1. Why a new script says "Permission denied"
  2. Add the execute bit with chmod +x
  3. Run the script
  4. Don't forget the shebang line
  5. The chmod 755 equivalent
  6. When to use which

Why a new script says "Permission denied"

You write a script, try to run it, and Linux throws this at you:

$ ./deploy.sh
bash: ./deploy.sh: Permission denied

Nothing is wrong with your code. By default a freshly created file is readable and writable, but not executable. Linux refuses to run a file unless its execute permission bit is set, and that's exactly what's missing here.

Add the execute bit with chmod +x

The fix is one command. chmod changes a file's mode, and +x adds the execute permission:

chmod +x deploy.sh

That +x grants execute to the user, group, and others at once (limited by your umask). Now Linux is allowed to run the file.

Run the script

With the bit set, run it by giving its path:

./deploy.sh

The ./ matters. It tells the shell "the script is right here in the current directory". Without it, the shell only searches the directories in your $PATH, and your script almost certainly isn't in one of those.

Don't forget the shebang line

The execute bit lets Linux run the file, but the file also needs to say which interpreter runs it. That's the job of the shebang, the very first line:

#!/bin/bash
echo "Deploying..."

#!/bin/bash tells the kernel to feed this file to Bash. For a more portable script you might use #!/usr/bin/env bash, which finds Bash via the PATH. Without a shebang, the script may run under whatever shell you happen to be in, which can bite you with subtle syntax differences.

The chmod 755 equivalent

You'll often see numeric permissions instead of the +x shorthand:

chmod 755 deploy.sh

This sets read, write, and execute for the owner (7), and read plus execute for the group and everyone else (5 and 5). For most scripts 755 is the sensible default. If a script holds secrets and only you should run it, use 700 instead so the group and others get nothing.

When to use which

For a quick "just let me run this", chmod +x is all you need. When you want exact, predictable permissions, reach for the numeric form like 755. If you want to really understand what those numbers mean and how owner, group, and other fit together, read my deeper guide on changing file permissions with chmod.

Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

Related articles

Argument list too long (Bash: /bin/rm)

Fix the Permission denied error when running a shell script by adding the execute bit with chmod +x, plus the shebang line and chmod 755.

Read more →

How to install Composer packages locally

Fix the Permission denied error when running a shell script by adding the execute bit with chmod +x, plus the shebang line and chmod 755.

Read more →