return 0
return 0

Reputation: 4366

Why I cannot changing the permission of executing a shellscript even as a root?

I have a run.sh file, I want to execute it from terminal by

./run.sh

However, it says

bash: ./run.sh: Permission denied

Then I tried to change the permission of executing it. I open the properties of that file, and go to permission tab, I checked the "Allow executing file as program". The check mark disappeared! It invalidated my check...

Then I tried to use

sudo chmod +x run.sh

and then

./run.sh

Then same permission problem happened... However, if I run it with

bash run.sh

it works. But I really want to fix the issue and go back to my habit of using ./ to execute shellscript. Can anyone help? Thanks.

Upvotes: 0

Views: 104

Answers (2)

Anoop
Anoop

Reputation: 5720

First of all, this is not the permission with respect to types, instead it is about user specific permission.

One possible explanation is your bash process might be running under root owner. Hence all applications you run as

bash script.sh

do not need superuser permission. If you run as

bash script.sh

you need to provide root password for it to work.

Upvotes: 1

A. Lefebvre
A. Lefebvre

Reputation: 139

Does your script run.sh have a shebang (First line of the script starting with #!) ?

Upvotes: 1

Related Questions