A difference between su
and ssh
is that the latter actually involves a login shell, whereas the former does not by default -- although it does create a new interactive shell (see INVOCATION at the top of man bash
for the significance of interactive and login shells). From man su
:
For backward compatibility su defaults to not change the current
directory and to only set the environment variables HOME and SHELL (plus USER and LOGNAME if the target user is not root). It is recommended to always use the --login option (instead of its shortcut -) to avoid side effects caused by
mixing environments.
So, you could try su --login
and see if that does what you want.
I'm presuming you're using a GUI, which is why you don't simply exit and log in again. However, that may be possible anyway (depending, I believe, on your init system), by simply running login
from whatever terminal you are using. If it works, you should see the normal login:
prompt, and when done you can exit
from that as per su
.