LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 03-29-2006, 04:12 AM   #1
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Rep: Reputation: 15
/root/bashrc PERMISSION DENIED when using runlevel 3


Hi all,
i'm having a strange problem for which i have already spent lot of hours try to understand what is happening,

NOTE: I am having this problem in 4 different Red Hat machines, very different each other.



THE PROBLEM IS:

When i am at runlevel 3, logged as root, if i try
to launch the command su username, to switch to another
user, all is ok but i always receive a message that says

"/bin/bash: /root/.bashrc permission denied"

Why is this happening?


WHAT THE PROBLEM CAUSES:

Nothing. It's strange but it doesn't nothing. It seems
that it wants to load for a normal user the root .bashrc (failing as you can image) instead of the user personal .bashrc, but it is not true because user personal .bashrc is loaded correctly without problem



MY ANALISYS:
I have seen that when logged as root, the account root
sets itself a variable called BASH_ENV="/root/.bashrc".
So this variable remains there also when you log as another user, and it is clearly that when the user find this variable it also finds an access denied response on that file, because it is a root personal file.
Now the strange thing is that trying to do the same at runlevel 5 doesn't produce this strange error even if the variable BASH_ENV still exists.
I have also tried to see if, with this error, there is an user environment problem, but all is ok because the user loads without problem his personal .bashrc file with all aliases i have set.


PAY ATTENTION, as mentioned before this happens in every red hat i have tried to use, exactely 4 machines different each other.

QUESTION NUMBER 1

So concluding is it normal to have this kind of error?
If I assume that the answer is "yes because that file /root/.bashrc is owned by root", how is it possible that runlevel 5 is able to hide it??

QUESTION NUMBER 2

Why linux set the BASH_ENV for user root? what is its work? I can assume that it indicates the .bashrc file of user root, but in this case, why normal users doesn't need it? i have seen that they haven't this variable but they can use their personal .bashrc file without problems

thanks in advance
 
Old 03-29-2006, 04:36 AM   #2
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
From the bash man page
Quote:
When bash is started non-interactively, to run a shell script, for
example, it looks for the variable BASH_ENV in the environment, expands
its value if it appears there, and uses the expanded value as the name
of a file to read and execute. Bash behaves as if the following com-
mand were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the PATH variable is not used to search for the file
name.
Also note
Quote:
BASH_ENV
If this parameter is set when bash is executing a shell script,
its value is interpreted as a filename containing commands to
initialize the shell, as in ~/.bashrc. The value of BASH_ENV is
subjected to parameter expansion, command substitution, and
arithmetic expansion before being interpreted as a file name.
PATH is not used to search for the resultant file name.
BASH_ENV could be set up in the bashrc file(/etc/bashrc). So your problem might be that it is being set up in bashrc file.
 
Old 03-30-2006, 04:29 AM   #3
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Original Poster
Rep: Reputation: 15
I have finally solved the problem but the mistery still remains

SOLUTION:
the problem is simply that in the bashrc file of the root user there
is a line which sets the variable BASH_ENV=~/.bashrc. The problem
is that in the bashrc file situated in the skel directory,which is the directory that contains standard files used when a new user is created, there isn't that line, so when switching to another user, the variable still remail BASH_ENV=/root/.bashrc, causing the error message ACCESS DENIED.
Now to solve the problem i have set the line BASH_ENV=~/.bashrc in the .bashrc file in the skel directory, so every new user will be created will have this line automatically added to their personal bashrc file, which will set the variable with their home directory

DOUBT STILL REMAINS:
However doubt still remains, why is there this variable? to maintain root user environment after logging with another user?
I don't know, but 2 things are sure


1) without this change, red hat cause an access denied error at runlevel 3
2) in reality the command "su" will execute user's .bashrc file and not the root one.
3) how is possible that runlevel 5 is able to hides this error while using gnome-terminal??

mhmmmm............

Last edited by Berkut83; 03-30-2006 at 04:32 AM.
 
Old 02-22-2010, 07:42 PM   #4
matticus_au
LQ Newbie
 
Registered: Aug 2007
Posts: 1

Rep: Reputation: 0
I found this in another article I was reading as I was receiving the same error:

"/bin/bash: /root/.bashrc permission denied"

When using 'su' to switch to another login use a '-' along with the command as it will change the shell to a login shell and thus implement all the environment variables for the login you are switching to.

For example:

su - myuser
 
Old 02-22-2010, 08:44 PM   #5
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
You probably need to read this.
http://www.linuxforums.org/forum/lin...on-denied.html
 
  


Reply



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
Permission denied as root Cadmium Mandriva 6 10-07-2005 12:00 PM
permission denied as root Foosed Slackware 6 06-06-2005 12:38 AM
su root permission denied exodist Linux - Software 4 07-23-2004 03:34 PM
Even as root, Permission Denied RevX Linux - Software 7 04-24-2004 11:10 PM
Permission denied as Root! Thewyzewun Linux - Newbie 3 03-13-2004 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 07:30 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
Open Source Consulting | Domain Registration