LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2016, 07:12 AM   #1
karanchhabra
LQ Newbie
 
Registered: Apr 2016
Posts: 9

Rep: Reputation: Disabled
Exclamation 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
 
Old 04-20-2016, 07:15 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,189

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
so what do you expect? without execute permission you are not able to execute....
 
Old 04-20-2016, 07:18 AM   #3
karanchhabra
LQ Newbie
 
Registered: Apr 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-20-2016, 07:22 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,788

Rep: Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162
Quote:
Originally Posted by karanchhabra View Post
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.
 
Old 04-20-2016, 07:23 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,788

Rep: Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162
Quote:
Originally Posted by karanchhabra View Post
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.
 
Old 04-20-2016, 07:25 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,148
Blog Entries: 4

Rep: Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716Reputation: 2716
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... ), 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.

Last edited by sundialsvcs; 04-20-2016 at 07:28 AM.
 
1 members found this post helpful.
Old 04-20-2016, 07:26 AM   #7
karanchhabra
LQ Newbie
 
Registered: Apr 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
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?
 
Old 04-20-2016, 07:30 AM   #8
karanchhabra
LQ Newbie
 
Registered: Apr 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thumbs up 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 View Post
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... ), 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.

Last edited by karanchhabra; 04-20-2016 at 07:41 AM.
 
Old 04-20-2016, 07:47 AM   #9
karanchhabra
LQ Newbie
 
Registered: Apr 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
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?
 
Old 04-20-2016, 10:40 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,788

Rep: Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162Reputation: 4162
Quote:
Originally Posted by karanchhabra View Post
@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.
 
1 members found this post helpful.
Old 04-20-2016, 10:45 AM   #11
karanchhabra
LQ Newbie
 
Registered: Apr 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thanks.

Quote:
Originally Posted by TB0ne View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] httpd.conf read-only, with file permissions -rw-r----- 1 root root httpd.con ostrosky.jeremiah Linux - Software 4 06-25-2013 12:10 AM
[SOLVED] Pass root permissions to user from a root script Ahaaa Programming 18 04-21-2012 10:53 PM
Member of group root, but root group permissions don't apply? aeternitas Linux - Software 7 04-21-2010 11:06 PM
Root permissions frostbite Linux - Newbie 7 08-06-2003 08:03 AM
root permissions explorer Linux - Newbie 3 03-06-2003 04:17 PM


All times are GMT -5. The time now is 07:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration