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
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?
As I understand it, "su" merely grants you root priveleges (changes your effective user/group IDs), while "su -" grants you a full login shell as the root user (hence the profile/environment changes).
He also pointed out that in other distros like Mandriva and Suse it is not the case.
I'm not certain, but 'su' might be aliased to 'su -' or something similar (perhaps for "user-friendliness"?)
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
On Thursday 11 May 2006 18:47, "Michael J. Knox" michael@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.
On 5/12/06, Chitlesh GOORAH chitlesh@fedoraproject.org wrote:
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 :)
It is the case, both Mandriva and Suse does not have /sbin in their default user path.