Root Permissions
Hi,
I am facing a strange situation, I have created an executable script file with nill permissions, i.e. --- --- --- (In my case). I am logged in as root, but I am able to read the content of the file, write into the file but "can't execute the file". On executing it says permission denied!!! The scenario is listed below: [root@rhcsa /]# ll -d /t.sh ----------. 1 root root 25 Apr 19 16:26 /t.sh [root@rhcsa /]# cat /t.sh echo "hello" && cd /home [root@rhcsa /]# vim /t.sh [root@rhcsa /]# cat /t.sh cd /home [root@rhcsa /]# /t.sh -bash: /t.sh: Permission denied [root@rhcsa /]# Thanks. Regards, Karan |
so what do you expect? without execute permission you are not able to execute....
|
I understand that without execute permission i can't execute a file but my question is "since this file has nill permissions i.e. NO PERMISSION FOR READ, NO PERMISSION FOR WRITE AND NO PERMISSION FOR EXECUTE, than why i am able to read write, but not execute.
Thanks, Karan |
Quote:
|
Quote:
|
As root, you have the sovereign ability to read and to write anything. (With certain system-protecting limits, in certain Unix/Linux systems ...)
But, the "Execute" bit is effectively an attribute of the file, which says that it makes sense to type-in the name of this file on the command-line, or to execute it as a program. If that attribute is not turned-on, Linux won't attempt to "execute it" ... for anyone, including you. Way back in the 1970's (koff, koff ... not that long ago, really... :hattip:), they didn't create a different error-code for this case: they simply re-used "permission denied." If this were not so, then the operating system would be behaving in a fundamentally different way for you, just because you have super-powers. It would try to execute a file that contained a copy of your grocery list, when it wouldn't do the same for any other user. It would promiscuously attempt to execute anything-at-all, just because you're "you." And that would be incorrect. |
My question is:
Why i am able to READ and WRITE even though their are no read and write permissions on the file and if the root user is allowed to READ and WRITE any file than WHY NOT EXECUTE? Permissions: rwx rwx rwx --- --- --- (No read, No write and No Execute) But the output varies: Read = Yes. Write = Yes. Execute = No.......WHY? |
Thanks.
Thank you for your help.
One question: who decides these system-protecting limits and how? Also how do i turn on the attribute for execute if i want to allow execute on anything? Quote:
|
root permissions
@sundialsvcs
One question: who decides these system-protecting limits and how? Also how do i turn on the attribute for execute if i want to allow execute on anything? |
Quote:
The "who decides" is the user creating the file. The operating system ENFORCES it. And read the man page on the chmod command...try "chmod 111" to set JUST the executable bit. |
Thanks.
Quote:
|
All times are GMT -5. The time now is 05:58 PM. |