Re: redhat/fedora distros: su versus su -

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 11 May 2006 18:47, "Michael J. Knox" <michael@xxxxxxxxxxx> 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@xxxxxxxxx

http://www.n-man.com/

LinkedIn:
http://www.linkedin.com/in/nman64

Have I been helpful?  Rate my assistance!
http://rate.affero.net/nman64/
-- 

Attachment: pgpADxOUkahcG.pgp
Description: PGP signature

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux