Re: root .bash_profile?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, May 13, 2019 at 04:20:17PM -0400, Bee.Lists wrote:
> > On May 13, 2019, at 2:46 PM, Pete Biggs <pete@xxxxxxxxxxxx> wrote:
> > 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`.

You'd find that if there's another user account on your system (lets
call it "fred"), and you ran 'su fred', it would not load
~fred/.bash_profile either, because it wasn't a login shell.  'root'
isn't special here.

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

As you read in the 'bash' man page, files that are loaded with a
"login shell" are different from files loaded from a normal shell
execution.  'su' has specific syntax for either running a shell as a
user or running a login shell as a user.  Just typing a password at
the prompt doesn't mean it was a login shell.

Typically, a 'login shell' is what you get when you log into a system
through login: or a graphical login.  .bash_profile is loaded once
when you log in.  It's meant for login stuff.  .bashrc is loaded for
every shell you start.

'su' is a tool used to switch users, so you are given the option to
either start a shell as a user or log in as that user, depending on
the situation.  

> 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.   

The 'su' man page explains all of this pretty well I think.  Becoming
root isn't special, in terms of loading .bash_profile vs. .bashrc.

-- 
Jonathan Billings <billings@xxxxxxxxxx>
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux