# Unable to Run Shell Scripts



## BriceH (Aug 24, 2009)

I'm working on learning shell scripting, and I made a shell script named helloworld.sh with the following code:

```
#!/bin/sh
echo Hello World
```

It's on my desktop, so in Terminal I put in the following commands to try to run it:
cd ~/Desktop
./helloworld.sh

When I do that, I get the following message:
-bash: ./helloworld.sh: Permission denied


What's the problem? How do I run my shell script?


----------



## artov (Aug 24, 2009)

The error message tells it. You do not have permission. Ok, since you created the file, it is your file and you have permission to read and edit it, but not to execute it. Normally text files are not to be executed, so you have to make it executable. Type:


chmod u+x ./helloworld.sh

and then you should be able to execute the file.

The chmod -command changes files permissions. "x" means that it can be executed. u+x means that your (u is for user) permission is changed, but not others.


----------



## BriceH (Aug 24, 2009)

artov said:


> The error message tells it. You do not have permission. Ok, since you created the file, it is your file and you have permission to read and edit it, but not to execute it. Normally text files are not to be executed, so you have to make it executable. Type:
> 
> 
> chmod u+x ./helloworld.sh
> ...


If I type 
chmod x ./helloworld
will it change permissions for everyone?


----------



## artov (Aug 25, 2009)

No, chmod x ./helloworld does not, but chmod +x ./helloworld does. (I guess the reason for + is that you can use chmod -x ./helloworld to remove the rights.)


----------

