redhat/fedora distros: su versus su -
Patrick W. Barnes
nman64 at n-man.com
Fri May 12 04:37:59 UTC 2006
On Thursday 11 May 2006 18:47, "Michael J. Knox" <michael at knox.net.nz> wrote:
> Chitlesh GOORAH wrote:
> > Hello here,
> > Last time at LinuxTag Wiesbaden, someone asked me why in RedHat/Fedora
> > distros,
> > /sbin is not in the PATH for _su_
> > example ifconfig
> > but as _su -_, /sbin is in the PATH?
> >
> > He also pointed out that in other distros like Mandriva and Suse it is
> > not the case.
> >
> > Can anyone answer this so that I could document myself :)
> >
> > regards,
> > Chitlesh Goorah
>
> su - takes the root user's enviroment varibles, su by itself does not.
> When you call just su, your (mortal users) enviroment varibles are used.
>
> Thats my understanding.
>
> Michael
I've not looked, but it is likely that those other distributions include /sbin
in the default PATH for regular users, which is the real cause of the
different behavior on those systems. 'su' and 'su -' actually behave the
same on those systems, but 'su' would inherit only the user's PATH settings,
so /sbin would be available only if it is in the user's PATH, which it is not
the default on Fedora. 'su -', which creates a login shell, would use only
root's PATH, which includes /sbin by default on Fedora. The tools
in /sbin, /usr/sbin and /usr/local/sbin are generally intended for use by
root, so it makes sense to exclude those paths for regular users.
As a side note, the same truths apply to sudo. Simple use of sudo to specify
a command will require an absolute path, while 'sudo bash --login' will
create a login shell and will provide /sbin in the PATH environment variable.
If a user prefers to have /sbin included in the PATH variable for regular
users, the adjustment can be made in ~/.bash_profile for each user or
system-wide by adding a new script in /etc/profile.d/ with lines that appear
as:
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
You can find the lines that provide the default behavior in /etc/profile. For
the sake of maintainability, you should not modify that file, but you can
override or extend it instead using the above outlined methods.
--
Patrick "The N-Man" Barnes
nman64 at n-man.com
http://www.n-man.com/
LinkedIn:
http://www.linkedin.com/in/nman64
Have I been helpful? Rate my assistance!
http://rate.affero.net/nman64/
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20060511/18f28777/attachment.sig>
More information about the fedora-devel-list
mailing list