others-How to solve insufficient permissions error when executing a script in linux

1. Purpose

In this post, I would demo how to solve the following error when executing a script in linux/unix/macos systems:

[[email protected] xxx]# ./h1.lua
-bash: ./h1.lua: Insufficient permissions

2. The solution

You should check the first line(shebang line) inside the script, for me, this is the first line:

[[email protected] xxx]# cat h1.lua

local i=0
while 1 do
  i = i+1
  if i>10000000 then

But when I type which lua to determine the lua engine, I got this:

[[email protected] xxx]# which lua

So the solution is to change the first line of the script from:


to :


One more thing about the shebang line :

The shebang is a special character sequence in a script file that specifies which program should be called to run the script. … Many scripting languages, such as Perl, use the # character to indicate the beginning of a comment line that should be ignored by the interpreter.

The name shebang for the distinctive two characters comes from an inexact contraction of SHArp bang or haSH bang, referring to the two typical Unix names for them. Another theory on the sh in shebang is that it is from the default shell sh, usually invoked with shebang.

3. Summary

In this post, I demonstrated how to solve the Insufficient permissions problem when executing a bash script in linux system, the key point is to check the first line of the script and make sure the path is correct. That’s it, thanks for your reading.