[CentOS] Setting PS1 for ordinary users

Bowie Bailey Bowie_Bailey at BUC.com
Wed Oct 10 15:58:43 EDT 2012


On 10/10/2012 3:48 PM, James B. Byrne wrote:
> 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$

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.

You can also look at the passwd file to see which shell is set.

-- 
Bowie


More information about the CentOS mailing list