|
OK, here is the full scoop on what is happening...
When a shell starts up it looks at its name. If it starts with a hyphen, it will act as a "login shell". Mostly this means that it will source some startup files in /etc and the user's home directory. For ksh, $HOME/.profile is a start-up file.
Do:
su
ps -fp $$
Since you just ran "su" your shell will be "sh" or something. Now exit the shell and try:
su - root
ps -fp $$
This time the name of the shell will be "-sh". So when this shell started up, it did indeed source the start-up scripts.
Every time that a shell starts it makes the test and sources the files if needed. When change .profile, you affect any new shell that is later started up with first character of its name set to hyphen. But pre-existing shells will need to manually source .profile.
|