Problem with su -

jdow jdow at earthlink.net
Mon Mar 5 22:07:17 UTC 2012


On 2012/03/05 13:47, Bob Goodwin wrote:
> On 05/03/12 15:08, jdow wrote:
>> On 2012/03/05 10:02, Emilio Lopez wrote:
>>>> finally settled things seem to work normally except I still get
>>>> that strange prompt "bash-4.2#" when it has always been
>>>> "[root at box6 bobg]#."
>>>
>>> I don't know if that helps but I have seen 'your strange prompt' doing this:
>>>
>>> [emilio at mipc]$ su
>>> password:
>>> [root at mipc]# su jhon
>>> bash-4.2#
>>>
>>> Emilio
>>
>> You might dig through your .bashrc, .bash_profile, /etc/bashrc, and /etc/profile
>> to see what has changed. I'd look for the string '\s\v', usually associated
>> with PS1 for the main prompt. But it might be PS2, 3, or 4 depending on the
>> gods of bash and what you've been doing.
>>
>> Then investigate why that got changed. (Since it is in your window session there
>> might even be an /etc/X11 change biting you.)
>>
>> {^_^}
>
> I have two computers set up identically and have spent the last
> hour trying to find a difference in the files you mention. If
> there is a dif. I missed it. I do see some stuff in
> /etc/X11/xinit that is dated 3 Mar. which is suspect, but I
> found no difference there yet ...
>
> [bobg at box9 ~]$ ll /etc/X11/xinit
> total 28
> -rwxr-xr-x. 1 root root 2030 Jul 25 2011 Xclients
> drwxr-xr-x. 2 root root 4096 Jul 25 2011 Xclients.d
> -rwxr-xr-x. 1 root root 1486 Jul 25 2011 xinitrc
> -rw-r--r--. 1 root root 2008 Jul 25 2011 xinitrc-common
> drwxr-xr-x. 2 root root 4096 Mar 3 12:09 xinitrc.d
> drwxr-xr-x. 2 root root 4096 Mar 3 12:09 xinput.d
> lrwxrwxrwx. 1 root root 26 Mar 3 12:09 xinputrc ->
> /etc/alternatives/xinputrc
> -rwxr-xr-x. 1 root root 3547 Jul 25 2011 Xsession
>
> I'm not certain but I would guess that's when this happened. I
> remeber finding that the XFCE file manager, Thunar, was missing
> and instaling that with yum or yumex, I forget which now, and
> having some trouble, removed and re-installed. That's probably
> when things changed. I shut it down and didn't boot it 'til today.
>
> Well it's minor, only thing I've found is that "ll" wont work if
> I su to root, have to use ls, that's minor.
>
> I don't think it's worth a lot of time, I am considering
> replacing that computer with another used one of slightly newer
> vintage. Got to see what FedEx brings ...
>
> Thanks,
>
> Bob

What does "set|grep PS" return to you? PS1 is likely your ill component. When
you see the actual string it has you can search for that. The string probably
does not look like the default. I think the default is '[\u@\h \W]\$ ' with the
single quotes.

Once you know the errant string you can look for it fairly easily if you
escape the backslashes. And with that in mind, bashrc has this string in it:
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

So it looks like you can expect to see that bash script under SOME conditions.
And reading that line leads me to suspect I need to look at "man bash". That
tells me this string is the default for a bash shell if nothing else sets the
prompt differently.

Is your /etc/bashrc file still there? And if it is look for the reason it
skips that line. This is the context in my SL6.2 install. The significant
line is the third one up from the bottom of my clipping.
===8<---
if [ "$PS1" ]; then
     case $TERM in
     xterm*)
         if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
             PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
         else
             PROMPT_COMMAND='echo -ne 
"\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
         fi
         ;;
     screen)
         if [ -e /etc/sysconfig/bash-prompt-screen ]; then
             PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
         else
             PROMPT_COMMAND='echo -ne 
"\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
         fi
         ;;
     *)
         [ -e /etc/sysconfig/bash-prompt-default ] && 
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
         ;;
     esac
     # Turn on checkwinsize
     shopt -s checkwinsize
     [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
     # setup mkd alias
     alias mkd=". /usr/local/bin/mkd"
===8<---

{^_^}


More information about the users mailing list