1

I have a script in one of I my root directory: /root/scripts/script1.sh

I wan't to call that script as another user (james1).

I did the following (as root user):

root@pc83$ CD scripts
root@pc83$ chown -R james1:user scripts
root@pc83$ CD scripts
root@pc83$ chmods 755 script1.sh

This made James 1 the owner of the script then I went to scripts directory and changed script1.sh permission to 755 which lets other execute.

Still when I connect as james1s and try to run script1. I can't.

james1@pc83$ /root/scripts/script.sh

I get permission denied error. Could some please let me know where I am going wrong? thanks.

I am using Oracle Enterprise Linux but tried to replicate the same problem in Ubuntu 10.10 and had the same issue.

migrated from stackoverflow.com Jan 17 '12 at 3:14

This question came from our site for professional and enthusiast programmers.

  • "Root directory" usually means / and not /root. – tripleee Jan 16 '12 at 10:38
1

Does james1 have permission to execute the root folder? That's needed for directly accessing files under /root/.

  • Hi Graham, you mean chown the root folder? – user1063304 Jan 16 '12 at 10:25
  • no, you just need to chmod. Whatever field applies to james1 (probably group or other) needs the +x bit. – user135 Jan 16 '12 at 10:34
  • No, he means does the current permission allow "other" to "execute"? Anyhow, put the script someplace like /usr/local/bin instead so you won't have to fiddle with permissions for /root - there's a reason they are somewhat tight. – tripleee Jan 16 '12 at 10:37
  • @tripleee Not sure what Graham meant by the +x but it gave me an idea which I tried and worked. "$ chmod +x root" and then "$chmod 755 dummies -R" doing that I can now run scripts. Looks like all in between directories (in my case root and script) has to have o+x as well. – user1063304 Jan 16 '12 at 13:14
  • The "+x" is usually called the execute bit, but on a directory it has a special meaning "allow users to access specific items inside this directory". This is different from the "read" bit, which means "allow users to list this directory's contents" and is needed to do ls. – user135 Jan 16 '12 at 13:27

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.