shell scripting & execution rights

2019-12-21

 | 

~1 min read

 | 

152 words

I was writing a small bash script the other day when I wanted to test it.

I went to try to execute the script and received a permission denied error:

$ ./setup.sh
zsh: permission denied: ./setup.sh

Looking at permissions, I could see that there were not execution rights for the file:

$ ls -la
-rw-r--r--     1 stephen  staff   671B Nov 19 13:28 setup.sh

It turns out that’s not a default right for a file. To fix that, you can change the file’s permissions with CHMOD1:

$ chmod +x setup.sh
$ ls -la
-rwxr-xr-x     1 stephen  staff   671B Nov 19 13:28 setup.sh

Footnotes

  • 1 While I used the -x flag only, there are other flags. The flags are: user (u), group (g), other (o), and all (a). For example, to change the execution rights for only users, you could do:
chmod u+x setup.sh

Related Posts
  • TS-Node: Running Typescript files as scripts


  • Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!