Why use "su -" rather than "su"
dgavin at davegavin.com
Fri Jul 15 16:59:56 UTC 2005
On Fri, July 15, 2005 12:33, Rick Stevens said:
> Mike McCarty wrote:
>> Paul Howarth wrote:
>>> Mike McCarty wrote:
>>>> I have a general *NIX admin question. Why does one want to use
>>>> su -
>>>> as opposed to just su? I think I understand the difference in regards
>>>> to "su -" actually changes you to root, as if logged in that way, as
>>>> opposed to simply granting root privilege. But why do that? If I do
>>>> that, then I lose my path settings, and can't run my normal editor,
>>>> is in ~/bin and so on. I just use "su".
>>>> What am I missing?
>>> You're missing getting /sbin and /usr/sbin on your PATH, which you
>>> probably want for what you're about to do as root. If you already have
>>> those directories on your regular user's PATH (which is not the
>>> default), "su -" probably doesn't help you much. But it does for most
>> Hmm. So I give up my regular editor in return for not having to type
>> Well, I think I'll go along the way I am. I'm a pretty good typist.
>> I thought there might be a *real* reason, and I had missed something. I
>> was wondering if there might be some subtle problems which would bite
>> me later.
> Actually, "su" will give you root's UID and GID, but not root's
> _environment_ (path and such). "su -" is roughly equivalent to doing
> a full-on login as root, and thus getting not only the UID and GID, but
> the environment as well.
> See "man su" for details.
"su -" also repositions you into root's home directory, which may not be
what you wanted.
Being shot out of a cannon will always be better than being squeezed
out of a tube. That is why God made fast motorcycles, Bubba....
"Song of the Sausage Creature" Hunter S. Thompson (RIP 02/20/2005)
More information about the users