Unix shell
missing image!
- Bash screenshot.png -
Screenshot of a sample Bash session, taken on Gentoo Linux.
A
Unix shell, is a
command line shell that provides the traditional
user interface for the
Unix operating system and for
Unix-like systems. Users direct the operation of the
computer by entering command input as text for a
command line interpreter to execute. The most generic sense of the term
shell means
any program that users use to type commands. Since in the Unix operating system users can select which shell they want to use (which program should execute when they login), many shells have been developed. It is called a "shell" because it hides the details of the underlying
operating system behind the shell's interface (in contrast with the "
kernel", which refers to the lowest-level, or 'inner-most' component of an operating system). Similarly,
graphical user interfaces for Unix, such as
GNOME,
KDE, and
Xfce can be called
visual shells or
graphical shells. By itself, the term
shell is usually associated with the command line. In Unix, any program can be the user's shell. Users who want to use a different syntax for typing commands can specify a different program as their shell.The term
shell also refers to a particular program, such as the
Bourne shell,
sh. The Bourne shell was the shell used in early versions of Unix and became a
de facto standard; every Unix-like system has at least one shell compatible with the Bourne shell. The Bourne shell program is located in the Unix file hierarchy at
/bin/sh. On some systems, such as
BSD,
/bin/sh is a Bourne shell or equivalent, but on other systems such as
Linux,
/bin/sh is likely to be a
link to a compatible, but more feature-rich shell.
POSIX specifies its standard shell as a strict subset of the
Korn shell.
Other types of shells
The Unix shell was unusual when first created. Since it is both an interactive command language and the language used to script the system, it is a
scripting programming language. Many shells created for other operating systems offer rough equivalents to Unix shell functionality.On systems using a
windowing system, some users may never use the shell directly. On Unix systems, the shell is still the implementation language of system startup scripts, including the program that starts the windowing system, the programs that facilitate access to the Internet, and many other essential functions.
On
MS-DOS,
OS/2, and
Windows, equivalents to Unix system scripts are called
batch files, and have either a ".bat" or ".cmd"
extension. A newer CLI -
Windows PowerShell, will replace the existing NT command line,
cmd.exe; it has many features derived from Unix shells, though it uses a somewhat different
syntax.Many users of a Unix system still find a modern command line shell much more convenient for many tasks than any
GUI application.Due to the recent movement in favor of
open source, most Unix shells have at least one version that is open source.
Shell categories
Unix shells can be broadly divided into four categories: Bourne-like, C Shell-like, nontraditional, and historical.
Bourne shell compatible
- Bourne shell (sh) -- Written by Steve Bourne, while at Bell Labs. First distributed with Version 7 Unix, circa 1978, and enhanced over the years.
- 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 for the occasion.
- Bourne-Again shell (bash) -- Written as part of the GNU project to provide a superset of Bourne Shell functionality.
- Debian Almquist shell (dash) -- Dash is a modern replacement for ash in Debian and is expected to be the default /bin/sh for Debian Lenny.
- Korn shell (ksh) -- Written by David Korn, while at Bell Labs.
- Z shell (zsh) -- considered as the most complete (read: the most features) shell: it is the closest thing that exists to a superset of sh, ash, bash, csh, ksh, and tcsh.
C shell compatible
Other or exotic
A list of various shells may be found at
www.freebsd.org.
Configuration files for shells
Shells read configuration files on multiple circumstances which differ depending on the shell. This table shows to configuration files for popular shells:{| class="wikitable"
| !style="text-align: center;font-weight: bold"|sh!style="text-align: center;font-weight: bold"|ksh!style="text-align: center;font-weight: bold"|csh!style="text-align: center;font-weight: bold"|tcsh!style="text-align: center;font-weight: bold"|bash!style="text-align: center;font-weight: bold"|zsh |
!style="background:#CFCFCF;text-align: left;font-weight: normal"|/etc/.login!style="background:#CFCFCF;text-align: center;font-weight: normal"|no!style="background:#CFCFCF;text-align: center;font-weight: normal"|no!style="background:#CFCFCF;text-align: center;font-weight: normal"|login!style="background:#CFCFCF;text-align: center;font-weight: normal"|login!style="background:#CFCFCF;text-align: center;font-weight: normal"|no!style="background:#CFCFCF;text-align: center;font-weight: normal"|no
|/etc/csh.cshrc!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|yes !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no
!style="background:#CFCFCF;text-align: left;font-weight: normal"|/etc/csh.login!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|login !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no
|~/.tcshrc!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|yes !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no
!style="background:#CFCFCF;text-align: left;font-weight: normal"|~/.cshrc!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|yes !style="background:#CFCFCF;text-align: center;font-weight: normal"|yes !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no
|~/.login!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|login !style="text-align: center;font-weight: normal"|login !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no
!style="background:#CFCFCF;text-align: left;font-weight: normal"|~/.logout!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|login !style="background:#CFCFCF;text-align: center;font-weight: normal"|login !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no
|/etc/profile!style="text-align: center;font-weight: normal"|login !style="text-align: center;font-weight: normal"|login !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|i.login !style="text-align: center;font-weight: normal"|no
!style="background:#CFCFCF;text-align: left;font-weight: normal"|~/.profile!style="background:#CFCFCF;text-align: center;font-weight: normal"|login !style="background:#CFCFCF;text-align: center;font-weight: normal"|login !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|login !style="background:#CFCFCF;text-align: center;font-weight: normal"|no
|~/.bash_profile!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|login !style="text-align: center;font-weight: normal"|no
!style="background:#CFCFCF;text-align: left;font-weight: normal"|~/.bash_login!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|login !style="background:#CFCFCF;text-align: center;font-weight: normal"|no
|~/.bashrc!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|n/login !style="text-align: center;font-weight: normal"|no
!style="background:#CFCFCF;text-align: left;font-weight: normal"|/etc/zshenv!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|yes
|/etc/zprofile!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|login
!style="background:#CFCFCF;text-align: left;font-weight: normal"|/etc/zshrc!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|int.
|/etc/zlogin!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|login
!style="background:#CFCFCF;text-align: left;font-weight: normal"|/etc/zlogout!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|login
|~/.zshenv!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|yes
!style="background:#CFCFCF;text-align: left;font-weight: normal"|~/.zprofile!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|login
|~/.zshrc!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|int.
!style="background:#CFCFCF;text-align: left;font-weight: normal"|~/.zlogin!style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|no !style="background:#CFCFCF;text-align: center;font-weight: normal"|login
|~/.zlogout!style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|no !style="text-align: center;font-weight: normal"|login
Explanation:
- "no" means a file is not read by a shell at all.
- "yes" means a file is always read by a shell.
- "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.
- "i.login" means a file is read if the shell is an interactive login shell.
Historic
Non-Unix shells
Within the
Microsoft Windows suite of operating systems the analogous programs are
command.com, or
cmd.exe for
Windows NT-based operating systems, and
Windows PowerShell introduced with
Windows Server 2008.
Further reading
- BOOK, Unix Shells by Example, Ellie Quigley, 2001, Prentice Hall PTR, ISBN 013066538X, Introduction to UNIX shells, — a history of the various shells, and the uses of and responsibilities of a shell on Unix
See also
External links
Unixový shellUnix-skalUnix-ShellUnix shellShell UnixUnix rendszerhéjシェル유닉스 셸Unix-skallShКомандная оболочка UNIXShเชลล์ยูนิกซ์Unix shell
(...as imported from WP)
article has not been saved locally