What is a Bourne shell?
The Bourne shell, also often referred to as /bin/sh or just sh, has been a default shell for users on FreeBSD for many major versions, while C shell was the default shell for root. From FreeBSD 14, the default shell for root is the Bourne shell.
Changing to Bourne shell on FreeBSD.
The shell for a user in FreeBSD can be changed with the chsh utility.
Configuring the Bourne shell in FreeBSD.
The Bourne shell in FreeBSD is configured by editing the global configuration file /etc/profile and/or the local user configuration file .shrc. These files contains commands, that will be executed, when the shell is started, such as when the user logs into the system.
In this example, the global configuration sets the blocksize for default file operations, ccache settings, the default editor, he default pager and a prompt. The prompt shows a “$” for a normal user and a “#” for root.
# nano /etc/profile BLOCKSIZE=K CCACHE=1 CCACHE_DIR=/var/cache/ccache EDITOR=/usr/local/bin/nano PAGER=less VISUAL=$EDITOR if [ "$(id -u)" -eq 0 ]; then PS1='# ' else PS1='$ ' fi export BLOCKSIZE CCACHE CCACHE_DIR EDITOR PAGER PS1 VISUAL
If the user would like to add or change custom settings, then this can be set in the local user configuration file. If this is not relavant, the file should be deleted, because it does contain settings, that could interfere with the global settings.
$ rm .shrc
# rm .shrc
Testing.
The Bourne shell can now be tested. In this example, a user log in and switch to root.
$ whoami
jennifer
$ su -
Password: Pencil
# whoami
root
# echo $EDITOR
/usr/local/bin/nano
The different kinds of shells.
There are different kinds of shells, such as login shells and sub-shells. The sub-shells are also known as non-login shells. The difference is, that a login shell reads global configuration files, while sub-shells just inherits the settings from the original shell. In this example, the first shell will be a login-shell, while the second will be a sub-shell.
FreeBSD/amd64 (wopr) (ttyv0)
Login: stephen
Password: Pencil
__ __________ ____________________
/ \ / \_____ \\______ \______ \
\ \/\/ // | \| ___/| _/
\ // | \ | | | \
\__/\ / \_______ /____| |____|_ /
\/ \/ \/
Greetings, professor Falken. How about a nice game of chess?
$ sh
$ su stephen
$ logout
$ logout