[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Speaking of logging in as root...



David Krider wrote:
Paul Johnson wrote:

su -m passes your current environment to your new one, thus your Xauth
gets passed on to root (and things running from that su can connect to
your X display).


Which is nice for running an X app as root, but I notice that some of
the extra paths (like /sbin) don't get added to your root environment,
which makes it a little more frustrating to actually *do* the sorts of
things one would `su' to root to do... It's a tradeoff.

dk





The paragraphs under "Description" in the su MAN page on my machine explains all this behaviour:

" su is used to become another user during a login session. Invoked without a username, su defaults to becoming the super user. The optional argument - may be used to provide an environment similiar to what the user would expect had the user logged in directly."

and:

" The current environment is passed to the new shell. The value of $PATH is reset to /bin:/usr/bin for normal users, or /sbin:/bin:/usr/sbin:/usr/bin for the super user. This may be changed with the ENV_PATH and ENV_SUPATH definitions in /etc/login.defs. When using the -m or -p options, the users environment is not changed."

Thus the "su -" command without any user defined will bring up a root login shell that uses root's environment. IF you use "su -m" you will get a root login shell with your current path. Try each of these and after login type in "echo $PATH" and see the difference.

The bottom line for me is if I want to temporarily become root to do some root things, I use "su -".... the "su -m" doesn't quite hack it for me usually.

I hadn't thought of this in terms of running X apps though, and I just tried it (su -m). It worked beautifully! Thanks! YMMV depending upon what you want to do....

MAN pages are quite useful.... guess I will have to quit just "reading" them and start "studying" them...<grin>.

Cheers,
-Don Spoon-






Reply to: