Behaviour of su(1)
fcondo at quinn.com
Fri Oct 31 12:27:41 PDT 2008
Use this syntax (both equivalent):
su - root
su -l root
You do have to specify the user with -l. Perhaps the man page could
On Oct 31, 2008, at 11:33 AM, Frédéric Perrin wrote:
> When I « su - » to root (after being logged in as my normal user), the
> LOGNAME env variable is still set to my previous user, as in :
> | fred at chameau:~% /usr/bin/su -l
> | Password:
> | root at chameau:~# echo $USER - $LOGNAME
> | root - fred
> As far as I can tell, this contradicts the fine manual that says :
> | -l Simulate a full login. The environment is discarded
> except for
> | HOME, SHELL, PATH, TERM, and USER.
> So I would have expected LOGNAME to be either empty or set by some
> startup script to be root. So, why is LOGNAME still equal to my
> user ? (and where is it set ? « grep -r LOGNAME /etc » doesn't turn up
> This is an issue because emacs, for instance, uses $LOGNAME to load
> init-file. I could always add « export LOGNAME=root » to my shell
> startup file, but this doesn't quite feel right...
> GNU su (as it is ocnfigured in Debian at least) resets LOGNAME to root
> in the same situation. (and by the way, GNU su seems broken : if I «
> -l root », I always get a 'Password incorrect' answer).
> As a side question, is it considered bad practice to set root's shell
> and locales to something else then the default ?
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org
More information about the freebsd-questions