[CentOS] root .bash_profile?

Mon May 13 21:39:14 UTC 2019
Valeri Galtsev <galtsev at kicp.uchicago.edu>


On 2019-05-13 16:25, Pete Biggs wrote:
> On Mon, 2019-05-13 at 16:20 -0400, Bee.Lists wrote:
>>> 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`.
> 
> If you switch to any other user using 'su', then their .bash_profile
> isn't loaded (unless you specify that it's a login shell).

Whole environment of user that invoked su is "inherited" unless it is 
specified on commend line to get login environment of user one does su into.

>  'su'
> doesn't mean "super user" it means "substitute user" - the default
> happens to be user UID 0.

Thanks Pete! This really needs to be repeated, even though whenever su 
is mentioned I repeat that to my users that it means "substitute user", 
but now that you mentioned it here it makes this whole thread clear.

Valeri

> 
>>
>>>> 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.
> 
> It may not be "just another user", but it *is* a user as much as your
> login username is a user. You could assign your own username a UID of
> 0, and it would have the same privileges as 'root', but it would still
> act as your username.  NOTE: doing this is NOT recommended, do not do
> it, seriously, do NOT do it.
> 
>>
>>>> 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?
> 
> No. It doesn't. The password prompt is for authentication, not logging
> in.
> 
>>
>> man su doesn’t apply to root with regards to the files loaded up upon
>> login.
> 
> Could you explain what you mean by that.
> 
> P.
> 
> 
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos
> 

-- 
++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++