I just wrote this simple script:
#!/bin/bash
echo hello world
And saved it on the desktop, but when i try to ./Script it says : bash: ./Script: permission denied
Why?
[Newbie] scipt permission denied?
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
[Newbie] scipt permission denied?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: [Newbie] scipt permission denied?
The script is not executable.
Here is one way to solve this:
HTH.
Here is one way to solve this:
Code: Select all
cd ~/Desktop
chmod +x Script
./Script
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 792 days now.
Lifeline
Re: [Newbie] scipt permission denied?
If you know how to navigate through your files with "ls" and "cd" you might like to know that doing "ls -l" displays the files permission.
You'll see a lot of "rwx". R is for read, W is for write, and X for eXecutable.
There is 3 occurence of that. The first is the permission of the "owner of the file" (you, cause you have created your script file !), the second is the right of "your group" and last, "the other rights".
If there is a "-" instead of a "r/w/x", that means that this permission is set as "deny". If you do a "ls -l PATHTOYOURSCRIPT" you'll normally see something beginning like that : -rw-
The first "-" is special. It's saying "this is a file". If not, you'll see a "d" for Directory.
What stands after is what I've explained before. What you want to see now is a beautiful -rwx that allows you to execute the script x)
Chmod is the command that can change that (karlchen instructions : chmod +x PATHTOYOURSCRIPT !).
You'll see a lot of "rwx". R is for read, W is for write, and X for eXecutable.
There is 3 occurence of that. The first is the permission of the "owner of the file" (you, cause you have created your script file !), the second is the right of "your group" and last, "the other rights".
If there is a "-" instead of a "r/w/x", that means that this permission is set as "deny". If you do a "ls -l PATHTOYOURSCRIPT" you'll normally see something beginning like that : -rw-
The first "-" is special. It's saying "this is a file". If not, you'll see a "d" for Directory.
What stands after is what I've explained before. What you want to see now is a beautiful -rwx that allows you to execute the script x)
Chmod is the command that can change that (karlchen instructions : chmod +x PATHTOYOURSCRIPT !).
Re: [Newbie] scipt permission denied?
will run it if it's not executable.bash ~/Desktop/.Script