CentOS-6 When I login as root I see this prompt: [root at vhost04 ~]# When I login as a non-priviledged user I see this instead: sh-4.1$ .bashrc and .bash_profile have identical contents in /root and /home/user. What causes the difference? Why? How does one change the default so that all normal users get a [userid at hostname pwd]$ prompt? I have loked in/etc/profile.d and /etc/bashrc and I cannot see what condition is triggering the different behaviour. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
James B. Byrne wrote:> CentOS-6 > > When I login as root I see this prompt: > > [root at vhost04 ~]# > > When I login as a non-priviledged user I see this instead: > > sh-4.1$ > > .bashrc and .bash_profile have identical contents in /root and > /home/user. What causes the difference? Why? How does one change > the default so that all normal users get a [userid at hostname pwd]$ > prompt? > > I have loked in/etc/profile.d and /etc/bashrc and I cannot see what > condition is triggering the different behaviour.I'd guess whether there's a ~/.bashrc. I've got mine set the way I want it; I don't remember a ~/.bashrc being automagically created for new users. mark
On 10/10/12 11:42 AM, James B. Byrne wrote:> When I login as root I see this prompt: > > > [root at vhost04 ~]# > > When I login as a non-priviledged user I see this instead: > > sh-4.1$ > > .bashrc and .bash_profile have identical contents in /root and > /home/user. What causes the difference? Why? How does one change > the default so that all normal users get a [userid at hostname pwd]$ > prompt? > > I have loked in/etc/profile.d and /etc/bashrc and I cannot see what > condition is triggering the different behaviour.what shell are your regular users configured for? sh reads .profile rather than .bash_profile if you want that to be a system-wide default, you can put it in /etc/profile which ALL shells read before they read any user stuff. -- john r pierce N 37, W 122 santa cruz ca mid-left coast
To clarify the situation. The ONLY difference in the shell setup for both root and an ordinary user is the name. As shown below they bith use the same shell, they both have exactly the same contents in .bashrc and .bash_profile. The file .profile exists for neither. And yet somehow they end up with totally different PS1 values. How this happens I wish to discover. Where is root getting its PS1 value set and why is root's prompt surrounded by []? The ordinary user's PS1 value is that of the bash default which indicates to me that it is not being set anywhere. There is a good deal of code given over to setting the PS1 value in /etc/bashrc but it seems to depend upon PS1 being already set. I can find no reference to PS1 in any file in/root and the oly reference in /etc/profile.d is in colorls.sh which seems to be testing PS1 for a zero length string (i.e unset value). Where is PS1 actually being set? sh-4.1$ which sh /bin/sh sh-4.1$ su -l Password: [root at vhost04 ~]# which sh /bin/sh [root at vhost04 ~]# diff .bashrc /home/byrnejb/.bashrc [root at vhost04 ~]# diff .bash_profile /home/byrnejb/.bash_profile [root at vhost04 ~]# ll .profile ls: cannot access .profile: No such file or directory [root at vhost04 ~]# ll /home/byrnejb/.profile ls: cannot access /home/byrnejb/.profile: No such file or directory [root at vhost04 ~]# [root at vhost04 ~]# echo $PS1 [\u@\h \W]\$ [root at vhost04 ~]# exit logout sh-4.1$ echo $PS1 \s-\v\$ sh-4.1$ -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
On: Wed Oct 10 15:58:43 EDT 2012 Bowie Bailey Bowie_Bailey at BUC.com wrote:> It doesn't matter where sh is pointing. What matters is the > shell configuration. > > I'm using bash here: > $ which sh > /bin/sh > $ echo $SHELL > /bin/bash > > So try 'echo $SHELL' instead of 'which sh' to see which shell > you are using.That seems to be the issue here. [root at vhost04 ~]# echo $SHELL /bin/bash sh-4.1$ echo $shell Examining the passwd file as suggested shows that root has :/bin/bash and ordinary users have /bin/sh. And yet, the difference in behaviour seems strange: sh-4.1$ /bin/sh --version GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. [root at vhost04 ~]# /bin/bash --version GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. As far as I can see the two invocations call the same program. And yet, replacing /bin/sh with /bin/bash in the ordinary user's passwd entry does indeed change the prompt to one identical to that used by root. Does anyone here know why this happens? -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
On 11/10/12 05:42, James B. Byrne wrote:> CentOS-6 > > When I login as root I see this prompt: > > > [root at vhost04 ~]# > > When I login as a non-priviledged user I see this instead: > > sh-4.1$ > > .bashrc and .bash_profile have identical contents in /root and > /home/user. What causes the difference? Why? How does one change > the default so that all normal users get a [userid at hostname pwd]$ > prompt? > > I have loked in/etc/profile.d and /etc/bashrc and I cannot see what > condition is triggering the different behaviour.The following line in /etc/bashrc [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " is changing the prompt for the root user from the default '\s-\v$ ', because the root user has '/bin/bash' as there shell. The ordinary users are just getting the default PS1 because they have there shell set to '/bin/sh', and hence, /etc/bashrc is not called. I suggest you change all normal (non-system) users to have '/bin/bash' as there default shell, and they will get the correct prompt, and a better shell. K -- Kahlil (Kal) Hodgson GPG: C9A02289 Head of Technology (m) +61 (0) 4 2573 0382 DealMax Pty Ltd (w) +61 (0) 3 9008 5281 Suite 1415 401 Docklands Drive Docklands VIC 3008 Australia "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can't get them together again, there must be a reason. By all means, do not use a hammer." -- IBM maintenance manual, 1925
On Wednesday 10 October 2012 19:42:32 James B. Byrne wrote:> CentOS-6 > > When I login as root I see this prompt: > > > [root at vhost04 ~]# > > When I login as a non-priviledged user I see this instead: > > sh-4.1$ > > .bashrc and .bash_profile have identical contents in /root and > /home/user. What causes the difference? Why? How does one change > the default so that all normal users get a [userid at hostname pwd]$ > prompt? > > I have loked in/etc/profile.d and /etc/bashrc and I cannot see what > condition is triggering the different behaviour. >Create a file called /etc/sysconfig/bash-prompt-xterm with contents #!/bin/bash echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD} [ `tty | sed -e "s:/dev/::"` ]\007" watch for line wrap in e-mail You can edit to suit your taste but the above gives [molloyt at mufc ~]$ Then make sure your users have bash as their shell in the password file not sh. Regards, Tony