3

What is the difference between different shells in Ubuntu:

$ cat /etc/shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
Volker Siegel
  • 13,065
  • 5
  • 49
  • 65

1 Answers1

5

Bash

Bash is the GNU Project's shell. Bash is the Bourne Again SHell. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.

The improvements offered by Bash include:

Command line editing
Unlimited size command history
Job Control
Shell Functions and Aliases
Indexed arrays of unlimited size
Integer arithmetic in any base from two to sixty-four.

Source:1

Dash

Dash is an acronym for Debian Almquist shell (dash). It is a Unix and Linux shell which is much smaller than bash but still aiming at POSIX-compliancy. dash is a POSIX-compliant implementation of /bin/sh that aims to be as small as possible. dash is a direct descendant of the NetBSD version of ash (the Almquist SHell), ported to Linux in early 1997. It was renamed to dash in 2002.

dash is the standard command interpreter for the Linux system. The current version of dash is in the process of being changed to conform with the POSIX 1003.2 and 1003.2a specifications for the shell. This version has many features which make it appear similar in some respects to the Korn shell, but it is not a Korn shell clone. Only features designated by POSIX, plus a few Berkeley extensions, are being incorporated into this shell.

Source:2

RBash

If Bash is started with the name rbash, or the --restricted or -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. A restricted shell behaves identically to bash with the exception that the following are disallowed or not performed:

Changing directories with the cd builtin.
Setting or unsetting the values of the SHELL, PATH, ENV, or BASH_ENV variables.
Specifying command names containing slashes.
Specifying a filename containing a slash as an argument to the . builtin command.
Specifying a filename containing a slash as an argument to the -p option to the hash builtin command.
Importing function definitions from the shell environment at startup.
Parsing the value of SHELLOPTS from the shell environment at startup.
Redirecting output using the ‘>’, ‘>|’, ‘<>’, ‘>&’, ‘&>’, and ‘>>’ redirection operators.
Using the exec builtin to replace the shell with another command.
Adding or deleting builtin commands with the -f and -d options to the enable builtin.
Using the enable builtin command to enable disabled shell builtins.
Specifying the -p option to the command builtin.
Turning off restricted mode with ‘set +r’ or ‘set +o restricted’. 

These restrictions are enforced after any startup files are read.

When a command that is found to be a shell script is executed (see Shell Scripts), rbash turns off any restrictions in the shell spawned to execute the script.

Source:3

sh

sh is the command name of the Bourne shell, the standard command language interpreter of Unix and many Unix-like operating systems, including Linux. sh is a command language interpreter that executes commands read from a command line string, the standard input, or a specified file.

The Bourne shell was developed in 1977 by Stephen Bourne at AT&T's Bell Labs in 1977. It was the default shell of Unix Version 7. Most Unix-like systems contain the file /bin/sh that is either the Bourne shell, or a symbolic link (or hard link) to a compatible shell.

Source:4

Mitch
  • 107,631
  • Current posix versions call sh the standard shell, sometimes also called POSIX Shell, “Bourne Shell” is of historic interest only. – eckes Mar 30 '19 at 16:08