Setting PS1 for ordinary users
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. Byrne mailto:ByrneJB@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 |
Setting PS1 for ordinary users
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 |
Setting PS1 for ordinary users
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. Byrne mailto:ByrneJB@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 |
Setting PS1 for ordinary users
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 |
Setting PS1 for ordinary users
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 |
Setting PS1 for ordinary users
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 |
Setting PS1 for ordinary users
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 |
Setting PS1 for ordinary users
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 |
Setting PS1 for ordinary users
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). -- 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 |
Setting PS1 for ordinary users
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 -- Jay Leafey - jay.leafey@mindless.com Memphis, TN _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos |
| All times are GMT. The time now is 04:51 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.