Problem with su -

Bob Goodwin bobgoodwin at wildblue.net
Tue Mar 6 12:26:05 UTC 2012


On 06/03/12 06:30, Ed Greshko wrote:
> On 03/06/2012 07:09 PM, Bob Goodwin wrote:
>> On 06/03/12 05:15, Ed Greshko wrote:
>>> OK.... You have an unmodified ~/.bash_profile and a slightly
>>> different ~/.bashrc from my fresh install. The differences are not
>>> significant. The bottom line is that in ~/.bashrc you have if [ -f
>>> /etc/bashrc ]; then . /etc/bashrc Which should source the file. The
>>> place where the setting of PS1 takes place is here....
>>>>         # Turn on checkwinsize
>>>>         shopt -s checkwinsize
>>>>         [ "$PS1" = "\\s-\\v\\\$ " ]&&   PS1="[\u@\h \W]\\$ "
>>> Basically it is saying....  if PS1 is set to '\s-\v\$ ' change it to
>>> '[\u@\h \W]\$ ' .
>>>
>>> So, it would seem, one of 2 things are going on.  Either the file isn't
>>> being sourced or it isn't set as expected.
>>>
>>> What I would do is modify /etc/bashrc to ....
>>>
>>>     shopt -s checkwinsize
>>>     echo "PS1 is set to $PS1">   /tmp/huh
>>>     [ "$PS1" = "\\s-\\v\\\$ " ]&&   PS1="[\u@\h \W]\\$ "
>>>
>>> And then perform an su -.
>>>
>>
>>
>>     Ok, is this what you are suggesting I do?
>>
>>            shopt -s checkwinsize
>>         #  [ "$PS1" = "\\s-\\v\\\$ " ]&&  PS1="[\u@\h \W]\\$ "
>>            echo "PS1 is set to $PS1">  /tmp/huh
>>            [ "$PS1" = "\\s-\\v\\\$ " ]&&  PS1="[\u@\h \W]\\$ "
> I am suggesting that you *add* the single line
>
> echo "PS1 is set to $PS1">  /tmp/huh
>
> directly after the line reading
>
> shopt -s checkwinsize
>
>
> In your next email you seem to have done what I've suggested and
> reported....
>
>                  bash-4.2# cat /tmp/huh
>                  PS1 is set to \s-\v\$
>
>               It does that ...
>
> You said you have this....
>
>         bash-4.2# ls /etc/bashrc*
>         /etc/bashrc  /etc/bashrc~  /etc/bashrc.wrkng
>
> I don't know what /etc/bashrc~ since I don't have one on my system.
> Maybe move that to /tmp or something and try again?


        I don't know but "/etc/bashrc~" may be peculiar to the text editor I have been using for years. e3, e3em actually which emulates some Emacs commands. The tilde indicates a backup copy of the changed file. I don't trust that so I made one too, /etc/bashrc.wrkng

I also note that "ll" doesn't seem to work. That is also troublesome 
since it would seem to indicate a problem with sourcing the files in 
/etc/profile.d. You do have a /etc/profile file?

    bash-4.2# ls /etc/profile.d
    bash_completion.sh  colorls.sh           lang.sh              vim.csh
    colorgrep.csh        gnome-ssh-askpass.csh  less.csh              vim.sh
    colorgrep.sh        gnome-ssh-askpass.sh   less.sh             
    which2.csh
    colorls.csh        lang.csh           udisks-bash-completion.sh 
    which2.sh

    There is an /etc/profile file but it is long, can send a copy if you
    want to see it.


  Another thing to try.... Move /etc/bashrc.wrkng back to /etc/bashrc 
and then "su -". You'll have the "bad" prompt. But then type ". 
/etc/bashrc" and see if there are any error messages.

    Did that and re-booted since there was no immediate change.

        [bobg at box6 ~]$ ssh bobg at box9
        bobg at box9's password:
        Last login: Tue Mar  6 07:20:06 2012
        [bobg at box9 ~]$ su
        Password:
        bash-4.2# su -
        -bash-4.2# . /etc/bashrc
        [root at box9 ~]#

    No error messages!





More information about the users mailing list