su'ing not sourcing .bash_profile

Jon Radel jon at radel.com
Fri Apr 24 19:54:31 UTC 2009


Daniel Underwood wrote:
> When I am logged in as a non-root user and I try to become root by
> entering "su" and typing the root password, the resulting bash prompt
> does not reflect the contents of /root/.bash_profile
> 
> My /root/.bash_profile contains (among other things):
> 
> export PS1="[\e[1;31m\]$(tput bold)\u$(tput sgr0)\[\e[0m\]@\h \w]\$ "
> 
> The point is to make the username ("root") display in BOLD and RED
> text.  After su'ing, the text is not bold nor red.  If I then enter
> "source ~/.bash_profile", however, the prompt displays correctly,
> showing "root" in bold and red text.
> 
> How come su'ing doesn't seem to effect everything in the
> /root/.bash_profile file?
> 
> Thanks,
> Daniel

Read the man page on the distinction between

su

and

su -

the latter probably being what you want to use.

-- 

--Jon Radel
jon at radel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3283 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090424/208e1026/smime.bin


More information about the freebsd-questions mailing list