[CentOS] root .bash_profile?
Pete Biggs
pete at biggs.org.uk
Mon May 13 18:46:52 UTC 2019
> ~/.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.
More information about the CentOS
mailing list