I'm interested in the Bourne Shell

I want to learn to use the default shell that comes with freeBSD called the Bourne Shell.

My concept is that the installer for freeBSD will have me create a root account. When logging in as root the shell I'll be in is the tch shell. However I want to use the Bourne Shell instead.

What I am learning is that after I have installed freeBSD I must install sudo.

This way I can use the Bourne Shell as a regular user and still have a way to install ports. I could use sudo to gain the privilege to use git or make and install ports.

Is this a valid plan? Is there anything I need to know about getting to the Bourne Shell and using sudo to install ports?

I want to avoid the tch shell by using sudo in the Bourne Shell.

Thanks
 
1. If you installed a recent version of FreeBSD sh was your default shell (unless you told the installer not to)
2. anyway you may change the shell by using chsh
3. you don't need to install sudo. you may just login as root to be root.
 
It's kinda difficult to take any of your comments seriously. No offense.

I want to learn to use the default shell that comes with freeBSD called the Bourne Shell.
FreeBSD comes with multiple shells. At least for now.

My concept is that the installer for freeBSD will have me create a root account. When logging in as root the shell I'll be in is the tch shell. However I want to use the Bourne Shell instead.
As such my previous comments: you acknowledge the fact that FreeBSD comes with multiple shells, yet still insist that there's a default shell somehow?

Defaults mean nothing with FreeBSD having the power to serve.

What I am learning is that after I have installed freeBSD I must install sudo.
Then I suggest you get yourself a new teacher. Because this makes no sense at all, also considering that both su and ksu are part of the base system.

This way I can use the Bourne Shell as a regular user and still have a way to install ports. I could use sudo to gain the privilege to use git or make and install ports.
This makes no sense what so ever. Shells have 0 meaning when it comes to OS privileges.

Not to mention that Bourne was a user default already, even when CSH was still a thing.
 
I want to learn to use the default shell that comes with freeBSD called the Bourne Shell.

My concept is that the installer for freeBSD will have me create a root account. When logging in as root the shell I'll be in is the tch shell. However I want to use the Bourne Shell instead.

What I am learning is that after I have installed freeBSD I must install sudo.

This way I can use the Bourne Shell as a regular user and still have a way to install ports. I could use sudo to gain the privilege to use git or make and install ports.

Is this a valid plan? Is there anything I need to know about getting to the Bourne Shell and using sudo to install ports?

I want to avoid the tch shell by using sudo in the Bourne Shell.

Thanks
I'm a former systems administrator and welcome your curiosity about the shell. It's an investigation whose benefits will pay dividends. Learning Bourne shell is a great idea. It's the base paradigm for the "sh-family" of shells like sh, bash, and zsh. Other shells are neat too: ksh (because it gave AT&T Unix a lot of horsepower and fancy features that were ported later to other shells). The "c-family" like tcsh and csh are neat too. Personally, I stick with the "sh-family." I'm just returning to FreeBSD after years of Linux and am enjoying modern sh (which has the majority of features I liked in bash).

I think some of the other assertions in your post are confused. Let's keep it simple. Let your root user use sh. Let your unprivileged user use sh. If ever you need to do something as root, switch to the root user with `su -`. You'll need the root password to do so. When certain workflows become annoying, then you might roll tools like "sudo" in.
 
preWarp Hi and welcome to the forum, don't mind the gnats LOL

"The sh utility is the standard command interpreter for the system."

I remember reading an outdated book that mentioned sh is standard root and tcsh is standard user shell. That information is incorrect according to my installation of FreeBSD 14.2: both accounts use the standard sh shell.

2. anyway you may change the shell by using chsh

you may install sudo if you want to but the su service is available. I prefer doas but it is your choice.
 
Programming in csh is considered harmful

Therefore, if you use csh or a derivative for interactive use, you have to learn two shells: One for interactive use and another for programmig. No way!

Furthermore, I recommend using a shell that is part of the base system. This way you are always comfortable on the command line, even when you are only on a rescue system, where shells from the Ports might not be available.

Therefore, the basic Bourne Shell as it is shipped with FreeBSD is ideal. I use it as my daily driver and for all simple scripting (for complex tasks I would use Python or similar).
 
Maybe the OP confuses (maybe just by a typing mismatch, only) the
sh - Bourne Shell,
which in its modern form since version 13 takes over for the csh - C-Shell as the prechosen default as root's login shell (which in former versions you better did not change at all [I once did...boy, what a brain teaser that was to not reinstall the whole system completely new by scratch...😂]), both are/were "standard", but not till-death-do-us-part (anything can be changed) shells on Unix and BSD (almost) since their dawn, with the
bash - Bourne Again Shell
which is the most popular, de-facto-standard shell on most Linux distros, but on FreeBSD does not come with the base system by default but needs to be installed extra (since personally I don't use bash this might have changed recently without I recognized?)

But I cannot tell if for root bash can be set simply by chsh as its default login shell, or if that may cause
trouble.

Anyway I agree with the other posters.
Personally I use and stick to tcsh for both user and root. But that's my own personal flavor, no reference at all. It's simply because I'm used to its keys, have my .cshrc settings, and just too lazy to learn another shell, since I can do anything what I like to do in the shell directly with "my" shell. Anything slightly complex I do in scripts (almost always sh, barely bash, never csh 🤪😂), sometimes python, sometimes perl, sometimes even C (there are (many) other choices and ways, too - FreeBSD is ...free and open...🥸)
If I came new to unixworld/FreeBSD I would learn and stick to sh - at least as my "default".
And - and this again is my own personal flavor, only - if I was interested in taking a peek into other shells besides sh (and [t]csh), I'd rather took a closer look at ksh and zsh first, even before bash. Since in my eyes (modern) sh provides all a good shell needs, while bash (IMO) is bloated too much with features I don't need but prefer scripting instead. Again: my very own personal taste and opinion; sophisticated hardcore bash-hackers may say otherwise.

Edit:
Sorry, to answer the actual headline of this topic, it was the least thing to link some sites may help you on learning sh(scripting):

Wikibooks: very good tutorial to start on shellscripting, alas german only
Learn X in Y minutes on bash
Adcanced bash scripting, not maintained anymore, but very elaborated and still very useful (many examples!)
...there are many others.
 
For learning shell, I highly recommend the book Shell Programming in Unix, Linux and OS X 4th Edition by by Stephen Kochan and Patrick Wood. The publisher is Addison-Wesley Professional. The book avoids using bash specific features, which is unique among books and tutorials for shell scripting. I've been able to use this as my primary source to help build several scripts for imaging flash drives and manipulating disks.
 
Therefore, if you use csh or a derivative for interactive use, you have to learn two shells: One for interactive use and another for programmig. No way!
Well, using 2 different shells like that can have its advantages.

One of the reasons I highly favor csh for the root user is because this somewhat forces you to stop and think about the things you're doing. For my regular account I rely on the Korn shell (shells/pdksh, vi mode enabled and all) but having that change in pace for root really helps me not to treat those sessions too casually.

Take for example the C shell's interactive use of a for ... in ... done loop; you literally get to type every command one after another instead of creating one huge oneliner (which is more common with both Bourne & Korn), which makes it much easier to keep taps on what you're about to execute, which I consider an important feat when working on a system as root.
 
You’re running csh and my shell is bash
You’re the tertiary storage; I’m the L1 cache
I’m a web crawling spider; you an Internet mosquito;
You thought the 7-layer model referred to a burrito
You’re a dialup connection; I’m a gigabit LAN
I last a mythical man-month; you a one-minute man
It’s like I’m running Thunderbird and you’re still stuck with Pine
Which is why I think it’s time for me to KILL DASH NINE

from kill dash nine lyrics :)
I must admit that's a good one, thank you! :)
I've read the entire lyrics and listened to the song because I never heard of this before and that's very funny, it reminds me some of the OpenBSD songs, same spirit.
 
But I cannot tell if for root bash can be set simply by chsh as its default login shell, or if that may cause trouble.
If you have bash installed (I do), it can be done easily with just chsh. And it does not cause trouble. That is unless you break your bash installation. For that reason, I have TWO additional root-like accounts: In addition to the usual "toor" account (which is root but using the other of csh/sh), I also set up a "rootsh" account, which uses the standard sh.

For about 20 years, I lived by the religion that all shell scripts that are "installed" (meaning copied to /usr/local/bin and /usr/local/sbin, or at least kept in ~/bin) must use only V7 Korn shell features. About a year or two I gave up on that, and decided that bash is always available on all my machines, and always will be, so now I put scripts with bash-isms into production. Note that not very much of my personal infrastructure is in shell scripts, since I tend to very quickly (at about 20 or 30 lines of script) from the a shell script to Python or Perl.

For the OP: There are a variety of O'Reilly books about how to use sh scripts, both from the console, and as a scripting language.
 
[…]
For about 20 years, I lived by the religion that all shell scripts that are "installed" (meaning copied to /usr/local/bin and /usr/local/sbin, or at least kept in ~/bin) must use only V7 Korn shell features. About a year or two I gave up on that, and decided that bash is always available on all my machines, and always will be, so now I put scripts with bash-isms into production.
[…]
Embedded systems are examples where the assumption of Bash being always available breaks.

So I took the opposite route: I started with the believe that everything was “Bash”, got my bloody nose and now do all scripting in POSIX Shell.
 
drsnx60 I decided to research Users Supplementary Documents using Google search and i found https://docs-archive.freebsd.org/44doc/usd/ in the results. I already downloaded the vi documents :) Thank you for mentioning the USD. I enjoy reading these documents. I know that they are outdated but it allows me to go back in time and learn from the pros that made this system so great. I am always interested in original documentation like this. To me, it is as good as good intellectually. I am still learning FreeBSD and Unix. Docs like this are fantastic pieces of literature.

I like to learn from the people that create the software that i use. I remember that i learned html by reading the introduction to html by Tim Berners-Lee, which was hosted at CERN in the early 2000s. I enjoyed it very much. I also remember reading about NCSA Mosaic in an article written by Marc Andreesen.

Charlie_ Thank you for the path to usd. I haven't looked at the src directory yet, so i didn't know that these documents existed in my system. Very nice of you to post :)

I'm definitely going to enjoy these documents. vi is somehing that i want to master and i just like sh shell.

Thanks again :)
 
Git for Windows provides bash.exe and sh.exe; I wanted to use one to do a sed and went with sh.

I only used Bash on Linux and sh on FreeBSD, but figure sh to be more widely-used/available, and Bash is basically extended sh.
 
You’re running csh and my shell is bash
You’re the tertiary storage; I’m the L1 cache
I’m a web crawling spider; you an Internet mosquito;
You thought the 7-layer model referred to a burrito
You’re a dialup connection; I’m a gigabit LAN
I last a mythical man-month; you a one-minute man
It’s like I’m running Thunderbird and you’re still stuck with Pine
Which is why I think it’s time for me to KILL DASH NINE

from kill dash nine lyrics :)

The kill dash nine song doesn't mention the Threadripper or the Revenge lib... 😏 or explain why all the USB/ethernet/HDMI/power ports on your laptop are female-gendered.
 
I have often thought about coming back to this post and responding. I have been using FreeBSD in Oracle Virtual Box and then I moved over to a Comet Lake based PC. I want to be able to do things with computers but I am not experienced enough to have a definite idea. I recently learned more about Linux than I ever knew beforehand by learning bash commands. It filled in gaps in my experience and opened my perspective and I could see more things to do. Before my efforts consisted of googling and getting someone else's commands that they used. So I got to thinking if I did the same with FreeBSD, in that case learning the Bourne shell commands, my view would then light on something new. In fact, things are going nicely. I wanted to see if I could add a desktop environment to FreeBSD. So far the experience has been more about finding the right package. On the PC, I got an intel AX210 based (iwlwifi), wifi card working. So then I was learning to use WPA_Supplicant. But when I was finished, of course the environment installed was nothing like an environment prepared by an open-source organization like is such with Linux Desktop(s). Then I found out about Ghost BSD. Now I am gaining the traction I need to think about FreeBSD when I think about open-source options. Now that it's been a couple weeks of getting some first things out of the way I'm going to foucus more specifically on Bourne Shell Commands. I am not sure what I will find out. I have no practical ideas. But with Linux when I learned bash commands gaps in my understanding were replaced and I was supprised by what I discovered. In that awakening I find that I need to start meeting the criteria for the dicipline. I need gain some mathematical maturity. After all they call them computers because everything software depends upon is mathematical. Just to name one thing that is holding me back from say getting into cryptography or computational applications like finance.
 
I recently learned more about Linux than I ever knew beforehand by learning bash commands. It filled in gaps in my experience and opened my perspective and I could see more things to do. Before my efforts consisted of googling and getting someone else's commands that they used. So I got to thinking if I did the same with FreeBSD, in that case learning the Bourne shell commands, my view would then light on something new.
Commands like ip on Linux aren't "bash" commands, ifconfig(8) isn't a FreeBSD "Bourne shell" command. Those commands have very little to do with the shell they run on, although many of those commands can be strung together using a shell script. You are just getting adjusted to using a "command line interface", or CLI, instead of configuring your system with a GUI.
 
Back
Top