Re: [CentOS] Setting PS1 for ordinary users

2012-10-11 Thread Tony Molloy
On Wednesday 10 October 2012 19:42:32 James B. Byrne wrote:
 CentOS-6
 
 When I login as root I see this prompt:
 
 
 [root@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@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@mufc ~]$ 

Then make sure your users have bash as their shell in the password file 
not sh.

Regards,

Tony





___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-11 Thread Mike Burger

-- 
Mike Burger
http://www.bubbanfriends.org

It's always suicide-mission this, save-the-planet that. No one ever just
stops by to say 'hi' anymore. --Colonel Jack O'Neill, SG1


 On Wed, Oct 10, 2012 at 03:48:23PM -0400, 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?

 James,

 Have a look in /etc/bashrc  (and scripts called from there, such
 as in /etc/profile.d).

 HTH,

To be more specific, look at the root user's .bashrc and the regular
user's .bashrc, and note whether or not they contain:

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

On my system(s), /etc/bashrc contains the specifics for setting $PS1. If
your system's /etc/bashrc contains the same, and the regular users'
.bashrc files are not calling /etc/bashrc, this may explain the lack of
appropriate prompt display.
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Setting PS1 for ordinary users

2012-10-10 Thread James B. Byrne
CentOS-6

When I login as root I see this prompt:


[root@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@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. Byrnemailto:byrn...@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

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread m . roth
James B. Byrne wrote:
 CentOS-6

 When I login as root I see this prompt:

 [root@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@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

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread John R Pierce
On 10/10/12 11:42 AM, James B. Byrne wrote:
 When I login as root I see this prompt:


 [root@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@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 pierceN 37, W 122
santa cruz ca mid-left coast

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread James B. Byrne
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@vhost04 ~]# which sh
/bin/sh
[root@vhost04 ~]# diff .bashrc /home/byrnejb/.bashrc
[root@vhost04 ~]# diff .bash_profile /home/byrnejb/.bash_profile
[root@vhost04 ~]# ll .profile
ls: cannot access .profile: No such file or directory
[root@vhost04 ~]# ll /home/byrnejb/.profile
ls: cannot access /home/byrnejb/.profile: No such file or directory
[root@vhost04 ~]#
[root@vhost04 ~]# echo $PS1
[\u@\h \W]\$
[root@vhost04 ~]# exit
logout
sh-4.1$ echo $PS1
\s-\v\$
sh-4.1$

-- 
***  E-Mail is NOT a SECURE channel  ***
James B. Byrnemailto:byrn...@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

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread Bowie Bailey
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@vhost04 ~]# which sh
 /bin/sh
 [root@vhost04 ~]# diff .bashrc /home/byrnejb/.bashrc
 [root@vhost04 ~]# diff .bash_profile /home/byrnejb/.bash_profile
 [root@vhost04 ~]# ll .profile
 ls: cannot access .profile: No such file or directory
 [root@vhost04 ~]# ll /home/byrnejb/.profile
 ls: cannot access /home/byrnejb/.profile: No such file or directory
 [root@vhost04 ~]#
 [root@vhost04 ~]# echo $PS1
 [\u@\h \W]\$
 [root@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
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread James B. Byrne
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@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@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. Byrnemailto:byrn...@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

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread Stephen Harris
On Wed, Oct 10, 2012 at 04:12:24PM -0400, James B. Byrne wrote:
 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?

Many programs may change behaviour, depending on the name they are
called by.

man bash

   --norc Do  not  read  and  execute  the  personal  initialization  file
  ~/.bashrc  if  the  shell  is interactive.  This option is on by
  default if the shell is invoked as sh.


-- 

rgds
Stephen
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread m . roth
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:
snip
 So try 'echo $SHELL' instead of 'which sh' to see which shell
 you are using.

 That seems to be the issue here.

 [root@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:
snip
 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?

This is *very* odd, that users are created using sh, which is supposed to
resemble the original Bourne shell. It has far fewer capabilities than any
of the later shells, and I have no idea why you'd want users screwing with
that. It's very much *not* used much any more

I'd change all users in /etc/password to bash, unless they've explicitly
requested something else - (t)csh, or zed, whatever.

  mark
  mark

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread Bowie Bailey
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@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@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
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread Woodchuck
On Wed, Oct 10, 2012 at 03:48:23PM -0400, 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?

James,

Have a look in /etc/bashrc  (and scripts called from there, such
as in /etc/profile.d).

HTH,

Dave
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread Kahlil Hodgson
On 11/10/12 05:42, James B. Byrne wrote:
 CentOS-6

 When I login as root I see this prompt:


 [root@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@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

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread Nux!
On 10.10.2012 19:52, m.r...@5-cent.us wrote:

 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.

New users' homedirs are populated from /etc/skell if you use useradd, 
which do contain a .bashrc (and more).

-- 
Sent from the Delta quadrant using Borg technology!

Nux!
www.nux.ro
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Setting PS1 for ordinary users

2012-10-10 Thread Jay Leafey

On 10/10/2012 04:43 PM, Nux! wrote:

On 10.10.2012 19:52, m.r...@5-cent.us wrote:


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.


New users' homedirs are populated from /etc/skell if you use useradd,
which do contain a .bashrc (and more).



Another way (there is ALWAYS another way!) to do this for new accounts 
is to modify the /etc/default/useradd file and set the SHELL= line to 
use the shell you want.  The unaltered file on my C6.3 box contains 
SHELL=/bin/bash.


Of course, that doesn't help on existing accounts.

YMMV
--
Jay Leafey - jay.lea...@mindless.com
Memphis, TN

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos