[CentOS] Setting PS1 for ordinary users

Kahlil Hodgson kahlil.hodgson at dealmax.com.au
Wed Oct 10 16:43:05 EDT 2012


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



More information about the CentOS mailing list