Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bash forgets enviroment variables when I do "su"
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
emerge_me
n00b
n00b


Joined: 19 Apr 2005
Posts: 59
Location: Alicante, España

PostPosted: Sat Apr 23, 2005 8:27 pm    Post subject: Bash forgets enviroment variables when I do "su" Reply with quote

Every time I do a "su" to change user, varialbes like PATH are not the same and others are gone. I don't want to do "source /etc/profile" every time I change user.

example:

Code:

bash-2.05b$ echo $PATH
/usr/kde/3.3/bin:.:.:/bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3.5-20050130:/opt/sun-jdk-1.4.2.08/bin
:/opt/sun-jdk-1.4.2.08/jre/bin:/opt/sun-jdk-1.4.2.08/jre/javaws:/usr/qt/3/bin:/usr/kde/3.3/bin

bash-2.05b$ su
Password:
bash-2.05b# su arturo
bash-2.05b$ echo $PATH
/usr/local/bin:/usr/bin:/bin


unmasking bash and installing the version 3 would help?
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Sat Apr 23, 2005 8:41 pm    Post subject: Reply with quote

You probably want to run
Code:
su -

_________________
KDE
Back to top
View user's profile Send private message
emerge_me
n00b
n00b


Joined: 19 Apr 2005
Posts: 59
Location: Alicante, España

PostPosted: Sat Apr 23, 2005 8:47 pm    Post subject: Reply with quote

Thank you very much. It worked perfectly.

I'm used to Mandrake and I've never had a problem with "su", I don't really know the difference between "su" and "su -".
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Sat Apr 23, 2005 8:59 pm    Post subject: Reply with quote

The difference is documented in the manpage. Maybe Mandrake has an alias that makes su become su -. Hm, probably not.
man su wrote:
The optional
argument - may be used to provide an environment similiar to what the
user would expect had the user logged in directly.

_________________
KDE
Back to top
View user's profile Send private message
emerge_me
n00b
n00b


Joined: 19 Apr 2005
Posts: 59
Location: Alicante, España

PostPosted: Sat Apr 23, 2005 10:29 pm    Post subject: Reply with quote

Thanks, I've tried it in Mandrake and it's the same, excep that when I use "su", the PATH is more complete, that's why I've never noticed that I made something wrong.

Next time I'll try to remeber to read the man first :oops: . I thought there was something wrong with bash and not with the su options :roll: .
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum