Problem with su -

James Wilkinson fedora at aprilcottage.co.uk
Tue Mar 6 08:35:00 UTC 2012


Aaron Konstam wrote:
> The only way you can get a prompt containig root is by using su - .
> su will only produce a root prompt  by starting as root. It it not
> posible to do this:
> 
>           [bobg at box6 ~]$ su
>              Password:
>              [root at box6 bobg]#

Emilio Lopez wrote:
> Im doing exactly this to become root for years with fedora with no
> problems. Why is this wrong?

The difference between su and su - , according to the man page, is that
su - gives you a login shell. Among other things, that means bash runs
/etc/profile and one of ~/.bash_profile, ~/.bash_login, or ~/.profile¹.
The default Fedora ~/.bash_profile runs ~/.bashrc, which runs
/etc/bashrc, but Aaron might have his own variants that don’t do this.
It’s possible that this means he doesn’t see “root” in his bash prompt
if he just does su.

Alternatively, Aaron might have meant that su on its own inherits a
number of settings (including $PATH) from the normal user session. In
particular, normal users (and what you get after a plain su) have */bin
entries in $PATH before the equivalent */sbin entry, whereas “real” root
(or what you get after running su -) has the */sbin entries before
*/bin. 

So
su
system-config-keyboard
will run /usr/bin/system-config-keyboard which is a symlink to consolehelper
but
su -
system-config-keyboard
will run /usr/sbin/system-config-keyboard

Hope this illuminates matters!

James.

¹ Bash will run the first file it can find out of those three.
-- 
E-mail:     james@ | You can accept the existence of rain without denying the
aprilcottage.co.uk | existence of umbrellas.
                   |     -- http://ozyandmillie.org/2006/om20060615.html


More information about the users mailing list