[CentOS] Setting PS1 for ordinary users

Bowie Bailey Bowie_Bailey at BUC.com
Wed Oct 10 16:23:49 EDT 2012


On 10/10/2012 4:12 PM, James B. Byrne wrote:
> 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?

When you call bash as 'sh', it changes its behavior to mimic the 
original 'sh' shell.  If you look closer, you'll notice that /bin/sh is 
actually just a link to '/bin/bash'.

-- 
Bowie


More information about the CentOS mailing list