--- richard@tortoise.demon.co.uk wrote:
Hi Chris,
I'd read the info on su at for example: http://www.icewalkers.com/Linux/Howto/mini/Path-7.html and other places.
Obviously I've not understood it.
On Wednesday 23 July 2003 00:24, richard@tortoise.demon.co.uk wrote:
I was unaware that if you su to root, you get a path (compiled into the kernel?)
No, it's set in /etc/profile.
that it seems you cant edit.
There's something wrong if you can't edit it.
If I log on as root, then echo $PATH shows lots of directorys. /root/.profile has nothing in it to modify roots path, so I assume the path is defined fully in /etc/profile
Yes, you're right. If you take a look at the file, you'll probably see something like: [ $(id -u) = "0" ] && { $PATH=/usr/bin:/usr/local/bin } || $PATH=/some/other/location export $PATH
If I log in as user1 and su to root (not su - ) then echo $PATH gives only:
/usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
which is neither the path for user1 nor that had I logged in directly as root.
So where does this path come from?
As I have said before "su -" gives a login shell, which means that /etc/profile, /etc/profile.local, ~/.profile are all sourced, should they exist and thus modify certain environment variables. I am telling you that /etc/profile in this instance *is* sourced when "su -" is given.
I don't think /etc/profile is executed if I su to root. If I put something like echo "here we are in /etc/profile" at the start of it, I never see the echo when I su
Of course not. I am taking that last sentence literally when you say "su" and not "su -". If you just "su", then yes, you will get to be user "root", but all that has done is to change your effective $UID and $GID. NO environment variables are modified with a plain "su". You should also notice that if you say "cd /home/some/user" and then "su root", the $(pwd) does not change, whereas if you "su -" then $(pwd) = /root. This is evident of a login shell and all the /etc/bashrc, ~/.bashrc, /etc/profile, etc files being sourced. HTH, -- Thomas Adam ===== Thomas Adam "The Linux Weekend Mechanic" -- www.linuxgazette.com ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://uk.messenger.yahoo.com/