[CentOS] root .bash_profile?

Bee.Lists bee.lists at gmail.com
Mon May 13 20:20:17 UTC 2019


> On May 13, 2019, at 2:46 PM, Pete Biggs <pete at biggs.org.uk> wrote:
> 
>> First, the ~ which might not apply to root. 
> 
> Why do you think that?  '~' is just shell shorthand for user's home
> directory.

root quite often isn’t recognized as a proper user.  ~/.bash_profile isn’t loaded because it’s not a normal login shell when entering `su`.  

>> Second, it’s a “personal” init file, which also might not pertain to
>> root.  
> 
> root is just as much a user as anyone else, albeit one with special
> privileges because they are UID 0.

So I can’t assume it’s just another user.  

>> Going from user to root (su) might not initiate a login shell.  I’m
>> not clear on this. 
> 
> Are you logging in? (i.e. typing the username and password at a login
> prompt.)  If not, then it's not a login shell.

Isn’t moving from my own user using su, then prompted for password count as a login?  

>> 
>> But, .bash_profile is not loading.
>> 
>> I have my aliases in another file called /root/.bash_aliases, which
>> is a duplicate of my /home/myuser/.bash_aliases which is NOW sourced
>> in my /root/.bashrc so it now works.
>> 
>> So ya, got it to work, but knowing the cascade of inclusions is
>> important.  root is as important to me as my normal user.  
>> 
> 
> Yes. If you are going to be playing around as root, then you really
> should know the consequences of what you are doing.  When I started
> using Unix 30mumble years ago, the perceived wisdom was *always* invoke
> su as /bin/su, those where the days when '.' was frequently in a users
> path and some nasty user might leave scripts called 'su' lying around
> waiting for an admin to occidentally execute them.  Second, invoke it
> as '/bin/su -', that way you clean out any user variables and only have
> the environment you have setup for root.

man su doesn’t apply to root with regards to the files loaded up upon login.  Consequences of reading generic man pages result in more than one option.  


Cheers, Bee






More information about the CentOS mailing list