
tcsh and sh shell windows on a
Mac OS X Leopard desktop
A Unix shell is a shell that provides a command-line user interface for a Unix-like operating system. A Unix shell provides a command language that can be used either interactively or for writing a shell script.
A user typically works within a Unix shell via a terminal emulator; however, direct access via serial hardware connections or a Secure Shell are common for server systems. Although use of a Unix shell is popular with some users, others prefer to use a graphical shell in a windowing system, such as those provided in desktop Linux distributions or macOS, instead of a command-line interface (CLI).
A user may have access to multiple Unix shells with one configured to run by default when the user logs in interactively. The default selection is typically stored in a user's profile (for example, in the local passwd file or in a distributed configuration system such as NIS or LDAP). A user may use other shells nested inside the default shell.
A Unix shell may provide many features including: variable definition and substitution, command substitution, filename wildcarding, stream piping, control flow structures (condition-testing and iteration), working directory context, and here document.
/bin/sh. But a number of compatible work-alikes are also available with various improvements and additional features. On many systems, sh may be a
symbolic link or
hard link to one of these alternatives:
- Almquist shell (ash): written as a BSD-licensed replacement for the Bourne Shell; often used in resource-constrained environments. The sh of FreeBSD, NetBSD (and their derivatives) are based on ash that has been enhanced to be POSIX conformant.
- Busybox: a set of Unix utilities for small and embedded systems, which includes 2 shells: ash, a derivative of the Almquist shell; and hush, an independent implementation of a Bourne shell.
- Debian Almquist shell (dash): a modern replacement for ash in Debian and Ubuntu
- Bourne-Again shell (bash): written as part of the GNU Project to provide a superset of Bourne Shell functionality. This shell can be found installed and is the default interactive shell for users on most Linux systems; it provides both interactive mode (implemented by GNU Readline) or script-mode.
- Korn shell (ksh): an enhanced version of the Bourne shell, written by David Korn based on the Bourne shell sources while working at Bell Labs
- Public domain Korn shell (pdksh)
- Z shell (zsh): a relatively modern shell that is partially backward compatible with bash. It's the default shell in Kali Linux since 2020.4 and macOS since 10.15 Catalina.
The POSIX standard specifies its standard shell as a strict subset of the Korn shell. From a user's perspective the Bourne shell was immediately recognized when active by its characteristic default command line prompt character, the dollar sign (/etc/csh.login
|
|
login |
login |
|
|
| /etc/ksh.kshrc |
|
int. |
|
|
|
|
| ~/.kshrc) |
int. |
int. |
|
|
int. |
|
| /etc/profile |
login |
login |
|
|
login |
login |
| ~/.bash_login |
|
|
|
|
login |
|
| /etc/zshenv |
|
|
|
|
|
yes |
| /etc/zlogin |
|
|
|
|
|
login |
| ~/.zprofile |
|
|
|
|
|
login |
| ~/.zlogout |
|
|
|
|
|
login |
Explanation:
- blank means a file is not read by a shell at all.
- "yes" means a file is always read by a shell upon startup.
- "login" means a file is read if the shell is a login shell.
- "n/login" means a file is read if the shell is not a login shell.
- "int." means a file is read if the shell is interactive.
~/.tcshrc not found
↑ Newer versions of the Bourne Shell only
↑ Available on systems that support the "User Portability Utilities option"; value of the variable must be an absolute path, and it is ignored "if the user's real and effective user IDs or real and effective group IDs are different."
↑ sh, but only if invoked as -o posix).
1 2 Only in sh/ksh compatibility mode (when invoked as bash, sh, ksh)
1 2 3 The first readable file in order of ~/.profile; and only --posix or