On my Fedora 14 developer machine I can add a sharedAliases.sh file to /etc/profile.d -- both my user and root user then have access to the shared aliases.
Switch over to remote CentOS 5.7 machine and what appears to be the exact same config, no dice, root user does not have access to the shared aliases.
This may be due to the fact that I SSH into the CentOS box, not sure. At any rate, the lame workaround has been to copy shared aliases into root user's .bashrc as it's the only way I've been able to get desired prefs into root (yes, I know I should sudo, but have been rolling with su for years).
Ideas appreciated, would prefer to not have to duplicate aliases if possible.
I suspect that you execute the
su
command without dash (-
), and if so, it will invoke an interactive non-login shell. Combine with you have only following in/root/.bashrc
:(not source
/etc/bashrc
)whereas if you directly login or use
su -
, it will invoke a login shell,/etc/profile
is read andsharedAliases.sh
will be execute.To see which file is read with different shells, adding logs to all these files by executing the following commands as root:
Create an test alias:
Now, login as normal user and use
su
, you will see something like this:and with
su -
: