0

Maybe this is for dummies, but i'm not sure. My directory has the permissions:

drwx------ 2 root   root 4096 oct 16 11:39 scripts

But the script have the permissions:

-rwxrwxrwx  1 user user   39 oct 16 17:32 script.sh

But when i try to execute the script i get

bash: script.sh: Permission denied

I don't understand what is happening, because user can't execute the script (the owner and group were changed manualy) and obviusly root can.

X3MBoy
  • 460

1 Answers1

1

The user doesn't have permission to access the directory, or use it as part of a path. That's what the execute bit on directories means.

If you were to chmod o+x scripts then the user would be able to use scripts in that directory, but could not create new things in it or get a directory listing (that requires the read bit).

Eric Renouf
  • 18,431
  • And only changing the x bit will be enough??? No need to change the group of the folder??? – X3MBoy Dec 04 '15 at 20:56
  • Right, the user isn't part of the root group (I assume) so the group permissions wouldn't matter – Eric Renouf Dec 04 '15 at 20:57
  • Though actually, the chmod I gave would also change the group, I should have said chmod o+x not a+x so I'll fix that, though it probably doesn't make much difference really – Eric Renouf Dec 04 '15 at 20:57
  • The a+x made the trick, but i think o+x is more especific. So, to finally understand, the complete path need to have the x bit? Each part (directory) of the path? – X3MBoy Dec 04 '15 at 21:01
  • Right, to include a directory in a path you're using (for any purpose) you must have execute permissions on it. So that ends up being the case for each part of the path, you have to have execute on every directory or you can't use it – Eric Renouf Dec 04 '15 at 21:02