A reader writes:
Here is the problem – when I su to become root I don’t have any aliases or any stuff in my path. I also am not sure were the .bash_profile for root goes and if it is even read when su’ing – please help thanks.
This is an interesting puzzle. By default, when you use the sudo command, your environment should travel with you since it’s just changing the effective user ID (or euid, if you want to be really geeky!). But su is another beast because it spawns a new subshell that should appear like it’s from that account, not you. So shell aliases and environment settings are not typically inherited properly. Usually, though, people who work with su use either su – acct or su -l acct (depending on what flavor of Unix) which makes the subshell act as if it were a login shell, sourcing all “rc” files, and similar. That’s probably what you want to use in this case.
In terms of where root has its “rc” files, the best way to ascertain that is to identify the HOME directory for the root account by using grep:
grep root /etc/passwd
Quite often, root has its home in the directory / or, sometimes, /home/root. You could then easily copy all of your own “rc” files into that directory to ensure that your root environment is functionally identical.
How do I get my enviroment to change back to my previous enviroment.