$ man bash (INVOCATION) When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. But the reference to .bash_profile has some unclear restrictions or boundaries: ~/.bash_profile The personal initialization file, executed for login shells First, the ~ which might not apply to root. Second, it?s a ?personal? init file, which also might not pertain to root. Going from user to root (su) might not initiate a login shell. I?m not clear on this. 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.> On May 13, 2019, at 1:17 PM, Christian, Mark <mark.christian at intel.com> wrote: > > $ man bash, search on INVOCATIONCheers, Bee
> ~/.bash_profile > The personal initialization file, executed for login shells > > First, the ~ which might not apply to root.Why do you think that? '~' is just shell shorthand for user's home directory.> 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.> 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.> > 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. P.
On Mon, May 13, 2019 at 01:39:27PM -0400, Bee.Lists wrote:> $ man bash (INVOCATION)You might also benefit from reading the man page for 'su', which will explain why running 'su -' is different from running 'su'. -- Jonathan Billings <billings at negate.org>
> 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