Join my Bash scripting course on Udemy 👀

Solving `permission denied` error for shell scripts

May 10, 2021  ‐ 1 min read

If try to run a script, whether it is written in Python, bash or something else, you may encounter an error saying Permission denied.

Lets say for example you have a file called which runs perfectly fine when you run it using a interpreter like:

$ bash ./
Hello World

However, you prefer to run it without the bash and use just the file name. Or later even as a command instead by adding it to your PATH.

In that case you may see the following error.

$ ./
bash: ./ Permission denied

This error indicates that the execute file permission is missing. In order to add this execute permission you use the chmod command, which is short for change file mode. By running the following command we can make the script executable.

$ chmod u+x ./

And as we now see this indeed did the trick. Make sure you have added the shebang comment though.

$ ./
Hello World