What is a command interpreter shell?

The different shells, also known as command interpreters, are utilities, that reads commands from the terminal or from a file and presents them for the operating system to execute. Shells can have features, such as command line editor, word completion, word listing, spelling correction, history mechanism and job control.

What is the default shell in FreeBSD?

The default shells, that are pre-installed in FreeBSD, are sh, tcsh and csh. The sh shell is based on Bourne and the other shels are based on C shell.

The default shell for a user in FreeBSD is sh. The default shell for root in FreeBSD up to version 13 is csh. The default shell for root from FreeBSD 14 is sh. It is common, that root and users have different shells assigned to their system accounts.

The main differences between the sh and csh shell is probably encountered, when doing shell script programming. One example is the support of functions, which is not supported in csh.

Assigning a default shell to a new user of FreeBSD.

Each user is assigned a default shell, that will be started, when the user logs into the system. In this example, the available shells are sh, csh, tsch, bash, rbash and git-shell. The default shell in this example is sh.

# adduser
Username: david
Full name: David Lightman
Login group [david]:
Login group is david. Invite foobar into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash rbash git-shell nologin) [sh]:
Home directory [/home/david]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password: Pencil
Enter password again: Pencil
Lock out the account after creation? [no]:
Username : david
Password : ********
Full Name : David Lightman
Uid : 1337
Class :
Groups : david
Home : /home/david
Home Mode :
Shell : /bin/sh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (david) to the user database.
Add another user? (yes/no): no

Changing command interpreter shell in FreeBSD.

A user can change the default shell with the default shell change utility chsh in FreeBSD. In the example, the shell is changed from sh to csh. If the default editor is vi, the user can press I and navigate the cursor to sh and edit the shell to csh. When done, the user can press Esc, semi-colon and W and Q to write the changes and quit the editor.

$ chsh
#Changing user information for david.
Shell: /bin/csh
Full Name: David Lightman
Office Location:
Office Phone:
Home Phone:
Other information:

The shell can also be changed with other utilities, such as pw, which is often used as root to manage local users and groups from the command line. In the following example, the user foobar uses pw to list current settings. Note, that the default prompt for a user in csh is different from sh.

% pw usershow david
david:*:1337:1337::0:0:David Lightman:/home/david:/bin/csh

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.

Login: david
Password: Pencil
$ sh
$ su david

More about shells.