Shell

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Shell

Brandon helsley
 
 
 
There has been a difference in the hash sign of the command line. When I'm logged in as user it is $. When I am logged in as root it is #, even when I do not execute a shell. Usually it was root@machine17#. How do I change it back? I have to do pwd instead of just knowing what directory I am in.
 

 

 

 
 
 
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Don Wilde
On 6/29/20, Brandon helsley <[hidden email]> wrote:
>
>
>
> There has been a difference in the hash sign of the command line. When I'm
> logged in as user it is $. When I am logged in as root it is #, even when I
> do not execute a shell. Usually it was root@machine17#. How do I change it
> back? I have to do pwd instead of just knowing what directory I am in.
>
>
The shell used for the root user is different than the shell used for
a regular user, csh is leaner but also meaner than sh in many ways.

Do some research: man csh.

You can also get more examples on the web; google 'freebsd csh set prompt'.

In order to modify your prompt, you need to alter the variable PS1 in
your .cshrc (C-shell startup file, note the starting '.') in your
/root directory. For your regular prompt, look in the .profile file in
/home/myuser.

I will warn you up front: the two shells are quite different. Save a
backup of each of these files before you alter them. If your computer
dumps you into shell mode without booting, having a .profile in /root
is also a good idea. From the emergency shell you can 'source
/home/myuser/.profile'
--
Don Wilde
****************************************************
* What is the Internet of Things but a system *
* of systems including humans?                     *
****************************************************
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Brandon helsley
In reply to this post by Brandon helsley
 
 
>
 

 
In order to modify your prompt, you need to alter the variable PS1 in
 
your .cshrc (C-shell startup file, note the starting '.') in your
 
/root directory. For your regular prompt, look in the .profile file in
 
/home/myuser.
 
>
 

 
.cshrc I found in the usr directory with .profile. I don't want to change the prompt for the usr, just for the csh shell for root. How do I do this if my .cshrc file is in usr directory?
 

 

 

 
 
 
 
>  
> On Jun 29, 2020 at 3:51 PM, Donald Wilde  <[hidden email]>  wrote:
>  
>  
>  On 6/29/20, Brandon helsley  <[hidden email]>  wrote:  >   >   >   >  There has been a difference in the hash sign of the command line. When I'm  >  logged in as user it is $. When I am logged in as root it is #, even when I  >  do not execute a shell. Usually it was root@machine17#. How do I change it  >  back? I have to do pwd instead of just knowing what directory I am in.  >   >  The shell used for the root user is different than the shell used for a regular user, csh is leaner but also meaner than sh in many ways. Do some research: man csh. You can also get more examples on the web; google 'freebsd csh set prompt'. In order to modify your prompt, you need to alter the variable PS1 in your .cshrc (C-shell startup file, note the starting '.') in your /root directory. For your regular prompt, look in the .profile file in /home/myuser. I will warn you up front: the two shells are quite different. Save a backup of each of these files before you alter them. If your com
puter dumps you into shell mode without booting, having a .profile in /root is also a good idea. From the emergency shell you can 'source /home/myuser/.profile' -- Don Wilde **************************************************** * What is the Internet of Things but a system * * of systems including humans? * ****************************************************
>  
     
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

David Christensen
In reply to this post by Don Wilde
On 2020-06-29 14:51, Donald Wilde wrote:

> On 6/29/20, Brandon helsley <[hidden email]> wrote:
>>
>>
>>
>> There has been a difference in the hash sign of the command line. When I'm
>> logged in as user it is $. When I am logged in as root it is #, even when I
>> do not execute a shell. Usually it was root@machine17#. How do I change it
>> back? I have to do pwd instead of just knowing what directory I am in.
>>
>>
> The shell used for the root user is different than the shell used for
> a regular user, csh is leaner but also meaner than sh in many ways.
>
> Do some research: man csh.
>
> You can also get more examples on the web; google 'freebsd csh set prompt'.
>
> In order to modify your prompt, you need to alter the variable PS1 in
> your .cshrc (C-shell startup file, note the starting '.') in your
> /root directory. For your regular prompt, look in the .profile file in
> /home/myuser.
>
> I will warn you up front: the two shells are quite different. Save a
> backup of each of these files before you alter them. If your computer
> dumps you into shell mode without booting, having a .profile in /root
> is also a good idea. From the emergency shell you can 'source
> /home/myuser/.profile'

+1


Another option is to set the shell program for 'toor' to whatever is
desired, and then use that account for system administration tasks:

2020-06-29 15:38:09 toor@f3 ~/f3.tracy.holgerdanske.com
# head -n 4 /etc/passwd | tail -n 2
root:*:0:0:Charlie &:/root:/bin/csh
toor:*:0:0:Bourne-again Superuser:/root:/usr/local/bin/bash


Note that this implies you enable logins for 'toor' and install bash(1).


(I would not change the shell for root, as this could break your system.)


David
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Don Wilde
In reply to this post by Brandon helsley
On 6/29/20, Brandon helsley <[hidden email]> wrote:

>
>
>>
>
>
>
> In order to modify your prompt, you need to alter the variable PS1 in
>
> your .cshrc (C-shell startup file, note the starting '.') in your
>
> /root directory. For your regular prompt, look in the .profile file in
>
> /home/myuser.
>
>>
>
>
>
> .cshrc I found in the usr directory with .profile. I don't want to change
> the prompt for the usr, just for the csh shell for root. How do I do this if
> my .cshrc file is in usr directory?

You mean _user_ directory, not /usr, right?

If you log in as root, you will be using a startup file in /root. If
you su root from your regular user directory, you can copy it into
that directory.

Both are preceded by one called /etc/csh.cshrc in /etc. That is loaded
first, and the one where your regular user has /home/user is used if
you su from a normal user. The local dot-file will supercede the
master one in /etc. Get how that works? It's pretty cool once you get
used to it.

When you are operating as root, execute cd /root, then do ls -al to
see the .cshrc. Mine has the path string in it with your desired
behavior.


>
>
>
>
>
>
>
>
>
>
>>
>> On Jun 29, 2020 at 3:51 PM, Donald Wilde  <[hidden email]>  wrote:
>>
>>
>>  On 6/29/20, Brandon helsley  <[hidden email]>  wrote:  >   >
>>   >   >  There has been a difference in the hash sign of the command line.
>> When I'm  >  logged in as user it is $. When I am logged in as root it is
>> #, even when I  >  do not execute a shell. Usually it was root@machine17#.
>> How do I change it  >  back? I have to do pwd instead of just knowing what
>> directory I am in.  >   >  The shell used for the root user is different
>> than the shell used for a regular user, csh is leaner but also meaner than
>> sh in many ways. Do some research: man csh. You can also get more examples
>> on the web; google 'freebsd csh set prompt'. In order to modify your
>> prompt, you need to alter the variable PS1 in your .cshrc (C-shell startup
>> file, note the starting '.') in your /root directory. For your regular
>> prompt, look in the .profile file in /home/myuser. I will warn you up
>> front: the two shells are quite different. Save a backup of each of these
>> files before you alter them. If your com
> puter dumps you into shell mode without booting, having a .profile in /root
> is also a good idea. From the emergency shell you can 'source
> /home/myuser/.profile' -- Don Wilde
> **************************************************** * What is the Internet
> of Things but a system * * of systems including humans? *
> ****************************************************
>>
>


--
Don Wilde
****************************************************
* What is the Internet of Things but a system *
* of systems including humans?                     *
****************************************************
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Manish Jain
In reply to this post by Brandon helsley


On 2020-06-30 02:44, Brandon helsley wrote:
>  
>  
>  
> There has been a difference in the hash sign of the command line. When I'm logged in as user it is $. When I am logged in as root it is #, even when I do not execute a shell. Usually it was root@machine17#. How do I change it back? I have to do pwd instead of just knowing what directory I am in.
>  

Hi Brandon/others,

It is often unnoticed that FreeBSD has a mirror of the root user
appropriately named toor (whose shell can be anything).

The better thing to do is :

1) Install bash and poshinit: pkg install bash poshinit
2) Modify the shell for the user toor: chsh -s /usr/local/bin/bash
3) Set the password for toor: passwd toor
4) Logout and login as toor, and run the command poshinit

poshinit will :

1) automatically adjust your bash prompt to the current directory

2) create a portable shell environment (stored under $HOME/.shell/) that
you can reuse across Bash/Zsh under any OS: FreeBSD/Linux/Cygwin

If you do not want to use poshinit, you can yourself put the following
into your .bashrc:

export PS1='`pwd` # '


Hope this helps,
Manish Jain
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Manish Jain
In reply to this post by Brandon helsley


On 2020-06-30 14:44, Manish Jain wrote:

>
>
> On 2020-06-30 02:44, Brandon helsley wrote:
>> There has been a difference in the hash sign of the command line. When
>> I'm logged in as user it is $. When I am logged in as root it is #,
>> even when I do not execute a shell. Usually it was root@machine17#.
>> How do I change it back? I have to do pwd instead of just knowing what
>> directory I am in.
>
> Hi Brandon/others,
>
> It is often unnoticed that FreeBSD has a mirror of the root user
> appropriately named toor (whose shell can be anything).
>
> The better thing to do is :
>
> 1) Install bash and poshinit: pkg install bash poshinit
> 2) Modify the shell for the user toor: chsh -s /usr/local/bin/bash
> 3) Set the password for toor: passwd toor
> 4) Logout and login as toor, and run the command poshinit
>
> poshinit will :
>
> 1) automatically adjust your bash prompt to the current directory
>
> 2) create a portable shell environment (stored under $HOME/.shell/) that
> you can reuse across Bash/Zsh under any OS: FreeBSD/Linux/Cygwin
>
> If you do not want to use poshinit, you can yourself put the following
> into your .bashrc:
>
> export PS1='`pwd` # '
>
>
> Hope this helps,
> Manish Jain

Typo :
"chsh -s /usr/local/bin/bash" -> "chsh -s /usr/local/bin/bash toor"
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Steve O'Hara-Smith
In reply to this post by Manish Jain
On Tue, 30 Jun 2020 14:44:34 +0530
Manish Jain <[hidden email]> wrote:

> It is often unnoticed that FreeBSD has a mirror of the root user
> appropriately named toor (whose shell can be anything).

        Traditionally root ran /bin/csh and toor ran /bin/sh to keep both
BSD and AT&T trained sysadmins happy, it really doesn't matter what login
shell root uses at work we use zsh, at home I use bash but you could even
use mc or vshnu.

        However the OP was concerned about the prompt (which many people
have correctly said involves setting PS1) rather than the shell.

--
Steve O'Hara-Smith <[hidden email]>
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Per Hedeland
On 2020-06-30 11:43, Steve O'Hara-Smith wrote:

> On Tue, 30 Jun 2020 14:44:34 +0530
> Manish Jain <[hidden email]> wrote:
>
>> It is often unnoticed that FreeBSD has a mirror of the root user
>> appropriately named toor (whose shell can be anything).
>
> Traditionally root ran /bin/csh and toor ran /bin/sh to keep both
> BSD and AT&T trained sysadmins happy, it really doesn't matter what login
> shell root uses at work we use zsh, at home I use bash but you could even
> use mc or vshnu.
>
> However the OP was concerned about the prompt (which many people
> have correctly said involves setting PS1) rather than the shell.

Yes, PS1 is what to set for /bin/sh and its relatives (e.g. bash,
zsh), but it has no effect for csh/tcsh - there you need to set
'prompt' (and the "formatting sequences" are also different). And it
seems the OP was primarily interested in root's prompt (i.e. csh by
default).

--Per


_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Polytropon
In reply to this post by Brandon helsley
On Mon, 29 Jun 2020 15:14:43 -0600, Brandon helsley wrote:
> There has been a difference in the hash sign of the command line.
> When I'm logged in as user it is $. When I am logged in as root
> it is #, even when I do not execute a shell.

After loggin in, a shell is _always_ executed (the so-called
login shell). On FreeBSD, the default is the C shell, but
maybe you have chosen a different shell?

You can always check your actual login shell with the following
command:

        echo $SHELL

You can check what prompt is defined (see below).



> Usually it was root@machine17#. How do I change it back? I have
> to do pwd instead of just knowing what directory I am in.

This depends on _which_ shell you are using. On FreeBSD, there
are the following possibilities:

/bin/sh - typically used for scripting or single-user mode

/bin/csh - default dialog shell, primarily for interactive use.

If you only get # and $ as a prompt character, it seems that
you accidentally changed from /bin/csh to /bin/sh. You now
have two options:

1. Start csh manually by entering "csh".

2. Change back to the C shell as login shell by entering
   the command "chsh" (change shell) and change /bin/sh
   to /bin/csh.

I would prefer number 2. ;-)

After making that change, you can check if the prompt is
now set correctly:

In /bin/sh, use:

        echo $PS1

in /bin/csh, use:

        echo $prompt

The second command should list a more complex string.

Note that the C shell per default uses # and % instead of
# and $ (like sh and bash and zsh) to differentiate between
root and non-root users.




--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Polytropon
In reply to this post by Brandon helsley
On Mon, 29 Jun 2020 16:35:56 -0600, Brandon helsley wrote:
> .cshrc I found in the usr directory with .profile. I don't want
> to change the prompt for the usr, just for the csh shell for root.
> How do I do this if my .cshrc file is in usr directory?

For root, /root/.cshrc is the correct file. There also is a
global file /etc/csh.cshrc for all instances of the C shell
(which users, including root, can override).



--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Polytropon
In reply to this post by Manish Jain
On Tue, 30 Jun 2020 14:44:34 +0530, Manish Jain wrote:
> If you do not want to use poshinit, you can yourself put the following
> into your .bashrc:
>
> export PS1='`pwd` # '

It is not required to make an external program call for bash;
like the C shell, it has "internal variables" that can be used.
For the standard UNIX prompt (in ~/.bashrc):

        export PS1="\u@\h:\w\$ "

This mimics the C shell's default prompt (in /etc/cshrc):

        set prompt = "%N@%m:%~%# "
        set promptchars = "%#"

The only difference of course is that the C shell uses #
and % instead of # and $.

For the ugly Linux-like prompt (in ~/.bashrc):

        export PS1="[\u@\h] \w \$ "

I cannot recommend this. ;-)



--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Polytropon
In reply to this post by Per Hedeland
On Tue, 30 Jun 2020 13:27:58 +0200, Per Hedeland wrote:

> On 2020-06-30 11:43, Steve O'Hara-Smith wrote:
> > On Tue, 30 Jun 2020 14:44:34 +0530
> > Manish Jain <[hidden email]> wrote:
> >
> >> It is often unnoticed that FreeBSD has a mirror of the root user
> >> appropriately named toor (whose shell can be anything).
> >
> > Traditionally root ran /bin/csh and toor ran /bin/sh to keep both
> > BSD and AT&T trained sysadmins happy, it really doesn't matter what login
> > shell root uses at work we use zsh, at home I use bash but you could even
> > use mc or vshnu.
> >
> > However the OP was concerned about the prompt (which many people
> > have correctly said involves setting PS1) rather than the shell.
>
> Yes, PS1 is what to set for /bin/sh and its relatives (e.g. bash,
> zsh), but it has no effect for csh/tcsh - there you need to set
> 'prompt' (and the "formatting sequences" are also different). And it
> seems the OP was primarily interested in root's prompt (i.e. csh by
> default).

The first message says that the prompt character is $, which would
not be the case (per default) if the C shell was chosen; so the
case probably is related to "shell changed from C shell to sh",
rather than "the dog ate my configuration files". ;-)

The command to use here is "chsh".


--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Per Hedeland
On 2020-06-30 14:39, Polytropon wrote:

> On Tue, 30 Jun 2020 13:27:58 +0200, Per Hedeland wrote:
>> On 2020-06-30 11:43, Steve O'Hara-Smith wrote:
>>> On Tue, 30 Jun 2020 14:44:34 +0530
>>> Manish Jain <[hidden email]> wrote:
>>>
>>>> It is often unnoticed that FreeBSD has a mirror of the root user
>>>> appropriately named toor (whose shell can be anything).
>>>
>>> Traditionally root ran /bin/csh and toor ran /bin/sh to keep both
>>> BSD and AT&T trained sysadmins happy, it really doesn't matter what login
>>> shell root uses at work we use zsh, at home I use bash but you could even
>>> use mc or vshnu.
>>>
>>> However the OP was concerned about the prompt (which many people
>>> have correctly said involves setting PS1) rather than the shell.
>>
>> Yes, PS1 is what to set for /bin/sh and its relatives (e.g. bash,
>> zsh), but it has no effect for csh/tcsh - there you need to set
>> 'prompt' (and the "formatting sequences" are also different). And it
>> seems the OP was primarily interested in root's prompt (i.e. csh by
>> default).
>
> The first message says that the prompt character is $, which would
> not be the case (per default) if the C shell was chosen; so the
> case probably is related to "shell changed from C shell to sh",
> rather than "the dog ate my configuration files". ;-)

This was definitely not my impression of the OP's *problem* - in
particular, the first message
https://lists.freebsd.org/pipermail/freebsd-questions/2020-June/290424.html
says "When I am logged in as root it is #, even when I do not execute
a shell. Usually it was root@machine17#. How do I change it back?",
and
https://lists.freebsd.org/pipermail/freebsd-questions/2020-June/290428.html
says "I don't want to change the prompt for the usr, just for the csh
shell for root".

--Per
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Polytropon
On Tue, 30 Jun 2020 15:21:06 +0200, Per Hedeland wrote:

> On 2020-06-30 14:39, Polytropon wrote:
> > On Tue, 30 Jun 2020 13:27:58 +0200, Per Hedeland wrote:
> >> On 2020-06-30 11:43, Steve O'Hara-Smith wrote:
> >>> On Tue, 30 Jun 2020 14:44:34 +0530
> >>> Manish Jain <[hidden email]> wrote:
> >>>
> >>>> It is often unnoticed that FreeBSD has a mirror of the root user
> >>>> appropriately named toor (whose shell can be anything).
> >>>
> >>> Traditionally root ran /bin/csh and toor ran /bin/sh to keep both
> >>> BSD and AT&T trained sysadmins happy, it really doesn't matter what login
> >>> shell root uses at work we use zsh, at home I use bash but you could even
> >>> use mc or vshnu.
> >>>
> >>> However the OP was concerned about the prompt (which many people
> >>> have correctly said involves setting PS1) rather than the shell.
> >>
> >> Yes, PS1 is what to set for /bin/sh and its relatives (e.g. bash,
> >> zsh), but it has no effect for csh/tcsh - there you need to set
> >> 'prompt' (and the "formatting sequences" are also different). And it
> >> seems the OP was primarily interested in root's prompt (i.e. csh by
> >> default).
> >
> > The first message says that the prompt character is $, which would
> > not be the case (per default) if the C shell was chosen; so the
> > case probably is related to "shell changed from C shell to sh",
> > rather than "the dog ate my configuration files". ;-)
>
> This was definitely not my impression of the OP's *problem* - in
> particular, the first message
> https://lists.freebsd.org/pipermail/freebsd-questions/2020-June/290424.html
> says "When I am logged in as root it is #, even when I do not execute
> a shell. Usually it was root@machine17#. How do I change it back?",
> and
> https://lists.freebsd.org/pipermail/freebsd-questions/2020-June/290428.html
> says "I don't want to change the prompt for the usr, just for the csh
> shell for root".

My impression about a possibly changed shell came from
the following line in the original message:

        When I'm logged in as user it is $.
        When I am logged in as root it is #,
        even when I do not execute a shell.

Those prompt characters make me guess that it's not the
C shell emitting them (because that would be % and #,
not $ and #), and as it has not been stated _which_ shell
has been used for root and user, I think it was an
understandable guess. ;-)




--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Don Wilde
In reply to this post by Polytropon
On 6/30/20, Polytropon <[hidden email]> wrote:
> On Tue, 30 Jun 2020 13:27:58 +0200, Per Hedeland wrote:
>> On 2020-06-30 11:43, Steve O'Hara-Smith wrote:
>> > On Tue, 30 Jun 2020 14:44:34 +0530
>> > Manish Jain <[hidden email]> wrote:
>> >
>> >> It is often unnoticed that FreeBSD has a mirror of the root user
>> >> appropriately named toor (whose shell can be anything).
>> >

Thank you all for adding to my initial answer to Brandon.

>> > Traditionally root ran /bin/csh and toor ran /bin/sh to keep both
>> > BSD and AT&T trained sysadmins happy, it really doesn't matter what
>> > login
>> > shell root uses at work we use zsh, at home I use bash but you could
>> > even
>> > use mc or vshnu.
>> >
>> > However the OP was concerned about the prompt (which many people
>> > have correctly said involves setting PS1) rather than the shell.
>>
>> Yes, PS1 is what to set for /bin/sh and its relatives (e.g. bash,
>> zsh), but it has no effect for csh/tcsh - there you need to set
>> 'prompt' (and the "formatting sequences" are also different). And it
>> seems the OP was primarily interested in root's prompt (i.e. csh by
>> default).

Ah... I'm still learning too. :D

>
> The first message says that the prompt character is $, which would
> not be the case (per default) if the C shell was chosen; so the
> case probably is related to "shell changed from C shell to sh",
> rather than "the dog ate my configuration files". ;-)
>
> The command to use here is "chsh".
>
I would add only one suggestion here, and that would be to consider
using bash-static and parking it in a place where it is available in
the event of an excruciating mishap.

The only concern with doing so is that doing so causes the (larger!)
bash-static kernel to be used everywhere. If you have lots of regular
users with console prompts, this could be painful.

I haven't done this, but it should be possible to install both
bash-static and bash. One would have to rename the first (bash-static)
to something other than 'bash' and add that to the /etc/shells file,
but after doing so also install the bash package with the
non-monolithic binary 'bash' and use that as the shell for regular
users.

Have I forgotten any concerns or steps in doing so? It seems to me
that the benefits of having full bash capability available for the
toor user, and having regular bash available (as opposed to sh or
tcsh) for regular users has marked advantages for users (such as
myself!) who are not csh adepts.

Brandon, this is getting esoteric. I hope you can follow and benefit
from the responses to your question!

--
Don Wilde
****************************************************
* What is the Internet of Things but a system *
* of systems including humans?                     *
****************************************************
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Brandon helsley
In reply to this post by Polytropon
 
 
 
 
>Brandon, this is getting esoteric. I hope you can follow and benefit
 
from the responses to your question!
 
 

 
Yes you all have been more than helpful. I've been learning very quickly! Thanks again.
 

 

 

 
 
 
 
 
>  
> On Jun 30, 2020 at 7:34 AM, Donald Wilde  <[hidden email]>  wrote:
>  
>  
>  On 6/30/20, Polytropon  edvax.de>  wrote:  >  On Tue, 30 Jun 2020 13:27:58 +0200, Per Hedeland wrote:  >>  On 2020-06-30 11:43, Steve O'Hara-Smith wrote:  >>   >  On Tue, 30 Jun 2020 14:44:34 +0530  >>   >  Manish Jain  <[hidden email]>  wrote:  >>   >   >>   >>  It is often unnoticed that FreeBSD has a mirror of the root user  >>   >>  appropriately named toor (whose shell can be anything).  >>   >  Thank you all for adding to my initial answer to Brandon.  >>   >  Traditionally root ran /bin/csh and toor ran /bin/sh to keep both  >>   >  BSD and AT&T trained sysadmins happy, it really doesn't matter what  >>   >  login  >>   >  shell root uses at work we use zsh, at home I use bash but you could  >>   >  even  >>   >  use mc or vshnu.  >>   >   >>   >  However the OP was concerned about the prompt (which many people  >>   >  have correctly said involves setting PS1) rather than the shell.  >>   >>  Yes, PS1 is what to set for /bin/sh and its relatives (e.g. bash,  >
>  zsh), but it has no effect for csh/tcsh - there you need to set  >>  'prompt' (and the "formatting sequences" are also different). And it  >>  seems the OP was primarily interested in root's prompt (i.e. csh by  >>  default). Ah... I'm still learning too. :D  >   >  The first message says that the prompt character is $, which would  >  not be the case (per default) if the C shell was chosen; so the  >  case probably is related to "shell changed from C shell to sh",  >  rather than "the dog ate my configuration files". ;-)  >   >  The command to use here is "chsh".  >  I would add only one suggestion here, and that would be to consider using bash-static and parking it in a place where it is available in the event of an excruciating mishap. The only concern with doing so is that doing so causes the (larger!) bash-static kernel to be used everywhere. If you have lots of regular users with console prompts, this could be painful. I haven't done this, but it should be possible to instal
l both bash-static and bash. One would have to rename the first (bash-static) to something other than 'bash' and add that to the /etc/shells file, but after doing so also install the bash package with the non-monolithic binary 'bash' and use that as the shell for regular users. Have I forgotten any concerns or steps in doing so? It seems to me that the benefits of having full bash capability available for the toor user, and having regular bash available (as opposed to sh or tcsh) for regular users has marked advantages for users (such as myself!) who are not csh adepts. Brandon, this is getting esoteric. I hope you can follow and benefit from the responses to your question! -- Don Wilde **************************************************** * What is the Internet of Things but a system * * of systems including humans? * **************************************************** _______________________________________________ [hidden email]  mailing list  https://lists.freebsd.
org/mailman/listinfo/freebsd-questions  To unsubscribe, send any mail to "[hidden email]"  
>  
     
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

D'Arcy Cain-3
In reply to this post by Don Wilde
On 2020-06-30 09:33, Donald Wilde wrote:
> I would add only one suggestion here, and that would be to consider
> using bash-static and parking it in a place where it is available in
> the event of an excruciating mishap.

I use bash for my user and root shell.  To deal with mishaps I set my shell
in passwd to sh and create a small .profile which mainly just has this line:

bash && exit 0

That way if bash is fine I run it and immediately exit when it does.  If
bash is missing or can't run then the exit is skipped and I am in sh so that
I can fix things.

--
D'Arcy J.M. Cain <[hidden email]>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 788 2246     (DoD#0082)    (eNTP)   |  what's for dinner.
IM: [hidden email], VoIP: sip:[hidden email]


signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Polytropon
In reply to this post by Don Wilde
On Tue, 30 Jun 2020 06:33:44 -0700, Donald Wilde wrote:
> I would add only one suggestion here, and that would be to consider
> using bash-static and parking it in a place where it is available in
> the event of an excruciating mishap.

This is usually where the "toor" user is interesting: It is
for interactive use, but in worst case, regular "root" will
always work as expected.



> The only concern with doing so is that doing so causes the (larger!)
> bash-static kernel to be used everywhere. If you have lots of regular
> users with console prompts, this could be painful.

You could "manually install" a statically-linked version of
bash into /bin, and make it root:wheel + chmod 4000 (setuid),
so no regular user can execute it; for them, make sure that
the location of bash, usually /usr/local/bin/bash, is
reflected in a $PATH where /usr/local/bin is before /bin
(quite unelegant, but should work).



> I haven't done this, but it should be possible to install both
> bash-static and bash. One would have to rename the first (bash-static)
> to something other than 'bash' and add that to the /etc/shells file,
> but after doing so also install the bash package with the
> non-monolithic binary 'bash' and use that as the shell for regular
> users.

That is an even better approach. :-)



On Tue, 30 Jun 2020 09:46:08 -0400, D'Arcy Cain wrote:
> I use bash for my user and root shell.  To deal with mishaps I set my shell
> in passwd to sh and create a small .profile which mainly just has this line:
>
> bash && exit 0
>
> That way if bash is fine I run it and immediately exit when it does.  If
> bash is missing or can't run then the exit is skipped and I am in sh so that
> I can fix things.

This is a very convenient idea which only requires one
little configuration file change. However, entering "bash"
and pressing Enter at sh's # prompt after entering single-
user mode would work, too - in worst case, you'll get an
error message. :-)

Another coding for your idea would be:

        exec bash || /bin/sh

So the initial sh process continues as bash, but if it
fails, "returns" to sh (starts one).

Sidenote: I also tend to start a dialog shell out of sh
in case I need more than one command or slightly longer
path or filename to enter...





--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Shell

Don Wilde
On 6/30/20, Polytropon <[hidden email]> wrote:
> On Tue, 30 Jun 2020 06:33:44 -0700, Donald Wilde wrote:
>> I would add only one suggestion here, and that would be to consider
>> using bash-static and parking it in a place where it is available in
>> the event of an excruciating mishap.
>
> This is usually where the "toor" user is interesting: It is
> for interactive use, but in worst case, regular "root" will
> always work as expected.

Yes, exactly. As one of my model train heroes once said, "In the event
of excruciating pain..." and the sign on his layout pointed to a
largish hammer. :)

>> The only concern with doing so is that doing so causes the (larger!)
>> bash-static kernel to be used everywhere. If you have lots of regular
>> users with console prompts, this could be painful.
>
[snip]

>> I haven't done this, but it should be possible to install both
>> bash-static and bash. One would have to rename the first (bash-static)
>> to something other than 'bash' and add that to the /etc/shells file,
>> but after doing so also install the bash package with the
>> non-monolithic binary 'bash' and use that as the shell for regular
>> users.
>
> That is an even better approach. :-)

Excellent. Glad you think so, Polytropon!

For completeness, one would also want to alter the /etc/group file for
the toor user, since it does not appear to be automatically created
any more, at least in my 12-STABLE system.

Since the 'mailing list etiquette' answer has already been written as
an Article on FreeBSD.org, and far better than I could do it (!!!), I
will apply myself to testing this process and writing an Article
describing this and submit it for comment and posting.

This way, our community has the benefit of the active development of
BASH by the GPL guys and also supporting the folks like me who are
surprised by TCSH behavior.

I believe it has value beyond just me, although it's pretty complex to
add as a section in the Handbook. :D
--
Don Wilde
****************************************************
* What is the Internet of Things but a system *
* of systems including humans?                     *
****************************************************
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
12