PDA

View Full Version : su to root and environment vars are lost


bonsaidouglas
8th January 2005, 03:23 AM
I'm trying to get in the habit of logging into my remote server with a regular user and then using "su" to get to root, but it seems like all the environment variables are lost... For example, after I su to root, I can't just use "useradd" but have to specify the full path "/usr/sbin/useradd".

Any tips on maintaining the environment vars or paths or whatever?

tchung
8th January 2005, 03:37 AM
Hello,

Try 'su -' instead of 'su'

For more information, 'man su'

Thomas

bonsaidouglas
8th January 2005, 04:08 AM
Nice that works! The man entry is a little wierd but makes sense now:

-, -l, --login
make the shell a login shell

thanks!