LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Root Permissions (https://www.linuxquestions.org/questions/linux-newbie-8/root-permissions-4175577923/)

karanchhabra 04-20-2016 07:12 AM

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

pan64 04-20-2016 07:15 AM

so what do you expect? without execute permission you are not able to execute....

karanchhabra 04-20-2016 07:18 AM

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

TB0ne 04-20-2016 07:22 AM

Quote:

Originally Posted by karanchhabra (Post 5533914)
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 /]#

So what's your question? The permissions VERY CLEARLY do not have an executable bit set....no executable bit means you CANNOT EXECUTE IT.

TB0ne 04-20-2016 07:23 AM

Quote:

Originally Posted by karanchhabra (Post 5533916)
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.

Because you OWN THE FILE.

sundialsvcs 04-20-2016 07:25 AM

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.

karanchhabra 04-20-2016 07:26 AM

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?

karanchhabra 04-20-2016 07:30 AM

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:

Originally Posted by sundialsvcs (Post 5533923)
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.


karanchhabra 04-20-2016 07:47 AM

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?

TB0ne 04-20-2016 10:40 AM

Quote:

Originally Posted by karanchhabra (Post 5533943)
@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?

Posting the same question twice isn't good.

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.

karanchhabra 04-20-2016 10:45 AM

Thanks.

Quote:

Originally Posted by TB0ne (Post 5534017)
Posting the same question twice isn't good.

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.



All times are GMT -5. The time now is 05:58 PM.