su & su -

Discuss Applications

su & su -

Postby agent007 » Sun Jun 01, 2003 3:53 am

Guys,

What the diff between the two?

007
agent007
administrator
administrator
 
Posts: 254
Joined: Wed Feb 12, 2003 11:26 pm

Postby Void Main » Sun Jun 01, 2003 3:58 am

According to "man su" adding the "-" makes the new shell a "login shell". So without the "-" you will retain your current user's environment (PATH etc) and with the "-" it will read the switched to user's profiles (profile, bashrc, etc) and set the PATH and other environment variables as if you had actually logged in as the switched to user.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Calum » Mon Jun 02, 2003 2:01 pm

well in my experience, in mandrake, su is the same command as su - however in other systems (red hat and slack) su does not load the profile of the user switched to, as stated above. However in slack (can't remember if same in RH) if i just do su in slack, i appear not to gain the new profile of root, but i also appear to lose some of the configuration that the previous user had. For example, if a user has ls --color aliased to ls (so ls always displays coloured output), this does not carry after the su -

perhaps this is not relevant, just my observations.
User avatar
Calum
guru
guru
 
Posts: 1343
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland

Postby Tux » Mon Jun 02, 2003 2:14 pm

Isn't that because you will gain root's bashrc and colours aren't turned on in it?
Might be, but to tell the truth I don't know where the colours setting is kept.
Tux
guru
guru
 
Posts: 689
Joined: Wed Jan 08, 2003 10:40 am

Postby Calum » Mon Jun 02, 2003 3:09 pm

nope, good batting thinkman, but not quite the full cigar.
there's no .bashrc in a user's home dir (much less root's) in slack, it prefferring to put a central /etc/profile, and i have never felt the need to change that setup. also, the other easy way to spot that is not happening is that if i su - to root, i get ls --color aliased in the normal way, but i do not if i do su with no -

if i understand you rightly...
User avatar
Calum
guru
guru
 
Posts: 1343
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland


Return to Applications

Who is online

Users browsing this forum: No registered users and 0 guests

cron