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.
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
On 10.10.2012 19:52, m.roth@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).
On 10/10/2012 04:43 PM, Nux! wrote:
On 10.10.2012 19:52, m.roth@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
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.
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$
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.
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
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?
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.
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'.
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
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
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