Unix shell
Encyclopedia
A Unix shell is a command-line interpreter or shell
Shell (computing)
A shell is a piece of software that provides an interface for users of an operating system which provides access to the services of a kernel. However, the term is also applied very loosely to applications and may include any software that is "built around" a particular component, such as web...

 that provides a traditional user interface
User interface
The user interface, in the industrial design field of human–machine interaction, is the space where interaction between humans and machines occurs. The goal of interaction between a human and a machine at the user interface is effective operation and control of the machine, and feedback from the...

 for the Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 and for Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 systems. Users direct the operation of the computer
Computer
A computer is a programmable machine designed to sequentially and automatically carry out a sequence of arithmetic or logical operations. The particular sequence of operations can be changed readily, allowing the computer to solve more than one kind of problem...

 by entering commands as text for a command line interpreter to execute or by creating text scripts of one or more such commands.

The most influential Unix shells have been the Bourne shell
Bourne shell
The Bourne shell, or sh, was the default Unix shell of Unix Version 7 and most Unix-like systems continue to have /bin/sh - which will be the Bourne shell, or a symbolic link or hard link to a compatible shell - even when more modern shells are used by most users.Developed by Stephen Bourne at AT&T...

 and the C shell
C shell
The C shell is a Unix shell that was created by Bill Joy while a graduate student at University of California, Berkeley in the late 1970s. It has been distributed widely, beginning with the 2BSD release of the BSD Unix system that Joy began distributing in 1978...

. The Bourne shell, sh, was written by Stephen Bourne at AT&T as the original Unix command line interpreter; it introduced the basic features common to all the Unix shells, including piping
Pipeline (Unix)
In Unix-like computer operating systems , a pipeline is the original software pipeline: a set of processes chained by their standard streams, so that the output of each process feeds directly as input to the next one. Each connection is implemented by an anonymous pipe...

, here documents, command substitution
Command substitution
In computing, command substitution is a facility originally introduced in the Unix shells that allows a command to be run and its output to be pasted back on the command line as arguments to another command...

, variables
Variable (programming)
In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...

, control structures
Control flow
In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated....

 for condition-testing and looping and filename wildcarding
Wildcard character
-Telecommunication:In telecommunications, a wildcard character is a character that may be substituted for any of a defined subset of all possible characters....

. The language, including the use of a reversed keyword to mark the end of a block, was influenced by ALGOL 68
ALGOL 68
ALGOL 68 isan imperative computerprogramming language that was conceived as a successor to theALGOL 60 programming language, designed with the goal of a...

.

The C shell
C shell
The C shell is a Unix shell that was created by Bill Joy while a graduate student at University of California, Berkeley in the late 1970s. It has been distributed widely, beginning with the 2BSD release of the BSD Unix system that Joy began distributing in 1978...

, csh, was written by Bill Joy
Bill Joy
William Nelson Joy , commonly known as Bill Joy, is an American computer scientist. Joy co-founded Sun Microsystems in 1982 along with Vinod Khosla, Scott McNealy and Andy Bechtolsheim, and served as chief scientist at the company until 2003...

 while a graduate student at University of California, Berkeley
University of California, Berkeley
The University of California, Berkeley , is a teaching and research university established in 1868 and located in Berkeley, California, USA...

. The language, including the control structures and the expression grammar, was modeled on C. The C shell also introduced a large number of features for interactive work, including the history and editing mechanisms, aliases, directory stacks, tilde notation, cdpath, job control and path hashing.

Both shells have been used as coding base and model for many derivative and work-alike shells with extended feature sets.

Concept

The most generic sense of the term shell means any program that users employ to type commands. A shell hides the details of the underlying operating system with the shell interface and manages the technical details of the operating system kernel interface, which is the lowest-level, or 'inner-most' component of most operating systems. In Unix-like operating systems users typically have many choices of command-line interpreters for interactive sessions. When a user logs in to the system, a shell program is automatically executed. The login shell may be customized for each user. In addition, a user is typically allowed to execute another shell program interactively.

The Unix shell was unusual when it was introduced. It is both an interactive command language
Shell (computing)
A shell is a piece of software that provides an interface for users of an operating system which provides access to the services of a kernel. However, the term is also applied very loosely to applications and may include any software that is "built around" a particular component, such as web...

 as well as a scripting programming language, and is used by the operating system as the facility to control (shell script
Shell script
A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language...

) the execution of the system. Shells created for other operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s than Unix, often provide similar functionality.

On systems with a windowing system
Windowing system
A windowing system is a component of a graphical user interface , and more specifically of a desktop environment, which supports the implementation of window managers, and provides basic support for graphics hardware, pointing devices such as mice, and keyboards...

, 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
Internet
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite to serve billions of users worldwide...

, and many other essential functions.

Graphical user interface
Graphical user interface
In computing, a graphical user interface is a type of user interface that allows users to interact with electronic devices with images rather than text commands. GUIs can be used in computers, hand-held devices such as MP3 players, portable media players or gaming devices, household appliances and...

s for Unix, such as GNOME
GNOME
GNOME is a desktop environment and graphical user interface that runs on top of a computer operating system. It is composed entirely of free and open source software...

, KDE
KDE
KDE is an international free software community producing an integrated set of cross-platform applications designed to run on Linux, FreeBSD, Microsoft Windows, Solaris and Mac OS X systems...

, and Xfce
Xfce
Xfce is a free software desktop environment for Unix and other Unix-like platforms, such as Linux, Solaris, and BSD – though recent compatibility issues have arisen with regard to BSD Unix platforms...

 are often called visual or graphical shells.

Bourne shell

The Bourne shell was one of the major shells used in early versions of the Unix operating system and became a de facto standard. It was written by Stephen Bourne at Bell Labs
Bell Labs
Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

 and was first distributed with Version 7 Unix
Version 7 Unix
Seventh Edition Unix, also called Version 7 Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commercialization of Unix by AT&T in the early 1980s...

, circa 1977. Every Unix-like system has at least one shell compatible with the Bourne shell. The Bourne shell program name is sh and it is typically located in the Unix file system hierarchy at /bin/sh. On many systems, however, /bin/sh may be a symbolic link
Symbolic link
In computing, a symbolic link is a special type of file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution. Symbolic links were already present by 1978 in mini-computer operating systems from DEC and Data...

 or hard link
Hard link
In computing, a hard link is a directory entry that associates a name with a file on a file system. . The term is used in file systems which allow multiple hard links to be created for the same file. This has the effect of creating multiple names for the same file, causing an aliasing effect: e.g...

 to a compatible, but more feature-rich shell than the Bourne shell. The POSIX
POSIX
POSIX , an acronym for "Portable Operating System Interface", is a family of standards specified by the IEEE for maintaining compatibility between operating systems...

 standard specifies its standard shell as a strict subset of the Korn shell
Korn shell
The Korn shell is a Unix shell which was developed by David Korn in the early 1980s and announced at USENIX on July 14, 1983. Other early contributors were AT&T Bell Labs developers Mike Veach, who wrote the emacs code, and Pat Sullivan, who wrote the vi code...

. From a user's perspective the Bourne shell was immediately recognized when active by its characteristic default command line prompt character, the dollar sign ($).

C shell

The C shell was developed by Bill Joy
Bill Joy
William Nelson Joy , commonly known as Bill Joy, is an American computer scientist. Joy co-founded Sun Microsystems in 1982 along with Vinod Khosla, Scott McNealy and Andy Bechtolsheim, and served as chief scientist at the company until 2003...

 for the Berkeley Software Distribution, a line of Unix operating systems derived from Unix and developed at the University of California, Berkeley. It was originally derived from the 6th Edition Unix shell (Thompson shell
Thompson shell
The Thompson shell was the first Unix shell, introduced in the first version of Unix in 1971, and was written by Ken Thompson.It was a simple command interpreter, not designed for scripting, but nonetheless introduced several innovative features to the command line interface and led to the...

). Its syntax is modeled after the C programming language. It is used primarily for interactive terminal use, but less frequently for scripting and operating system control. C shell has many interactive commands.

Bourne shell compatible

  • Bourne shell
    Bourne shell
    The Bourne shell, or sh, was the default Unix shell of Unix Version 7 and most Unix-like systems continue to have /bin/sh - which will be the Bourne shell, or a symbolic link or hard link to a compatible shell - even when more modern shells are used by most users.Developed by Stephen Bourne at AT&T...

     (sh) -- Written by Steve Bourne, while at Bell Labs
    Bell Labs
    Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

    . First distributed with Version 7 Unix
    Version 7 Unix
    Seventh Edition Unix, also called Version 7 Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commercialization of Unix by AT&T in the early 1980s...

    , 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
    FreeBSD
    FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...

    , NetBSD
    NetBSD
    NetBSD is a freely available open source version of the Berkeley Software Distribution Unix operating system. It was the second open source BSD descendant to be formally released, after 386BSD, and continues to be actively developed. The NetBSD project is primarily focused on high quality design,...

     (and their derivatives) are based on ash that has been enhanced to be POSIX
    POSIX
    POSIX , an acronym for "Portable Operating System Interface", is a family of standards specified by the IEEE for maintaining compatibility between operating systems...

     conformant for the occasion.
  • Bourne-Again shell (bash) -- Written as part of the GNU Project
    GNU Project
    The GNU Project is a free software, mass collaboration project, announced on September 27, 1983, by Richard Stallman at MIT. It initiated GNU operating system development in January, 1984...

     to provide a superset of Bourne Shell functionality.
  • Debian Almquist shell
    Debian Almquist shell
    The Debian Almquist shell is a Unix shell, much smaller than bash but still aiming at POSIX-compliancy. It requires less disk space but is also less feature-rich.- History :...

     (dash) -- Dash is a modern replacement for ash in Debian
    Debian
    Debian is a computer operating system composed of software packages released as free and open source software primarily under the GNU General Public License along with other free software licenses. Debian GNU/Linux, which includes the GNU OS tools and Linux kernel, is a popular and influential...

     and Ubuntu
    Ubuntu (operating system)
    Ubuntu is a computer operating system based on the Debian Linux distribution and distributed as free and open source software. It is named after the Southern African philosophy of Ubuntu...

    .
  • Korn shell
    Korn shell
    The Korn shell is a Unix shell which was developed by David Korn in the early 1980s and announced at USENIX on July 14, 1983. Other early contributors were AT&T Bell Labs developers Mike Veach, who wrote the emacs code, and Pat Sullivan, who wrote the vi code...

     (ksh) -- Written by David Korn, while at Bell Labs
    Bell Labs
    Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

    .
  • mksh -- Descendant of the OpenBSD
    OpenBSD
    OpenBSD is a Unix-like computer operating system descended from Berkeley Software Distribution , a Unix derivative developed at the University of California, Berkeley. It was forked from NetBSD by project leader Theo de Raadt in late 1995...

     /bin/ksh and pdksh, developed as part of MirOS BSD
    MirOS BSD
    MirOS BSD is a free and open source operating system, which started as a fork of OpenBSD 3.1 in August 2002. It is intended to maintain the security of OpenBSD - from which it frequently synchronises code updates - with better support for European localisation...

    .
  • Z shell
    Z shell
    The Z shell is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting...

     (zsh) -- considered as the most complete (read: the one with the most features) shell: it is the closest thing that exists to a superset of sh, ash, bash, csh, ksh, and tcsh.
  • Busybox
    BusyBox
    BusyBox provides several stripped-down Unix tools in a single executable. It runs in a variety of POSIX environments such as Linux, Android, FreeBSD and others, such as proprietary kernels, although many of the tools it provides are designed to work with interfaces provided by the Linux kernel. It...

     -- Tiny utilities for small and embedded systems, include a shell.

C shell compatible

  • C shell
    C shell
    The C shell is a Unix shell that was created by Bill Joy while a graduate student at University of California, Berkeley in the late 1970s. It has been distributed widely, beginning with the 2BSD release of the BSD Unix system that Joy began distributing in 1978...

     (csh) Written by Bill Joy
    Bill Joy
    William Nelson Joy , commonly known as Bill Joy, is an American computer scientist. Joy co-founded Sun Microsystems in 1982 along with Vinod Khosla, Scott McNealy and Andy Bechtolsheim, and served as chief scientist at the company until 2003...

    , while at the University of California, Berkeley
    University of California, Berkeley
    The University of California, Berkeley , is a teaching and research university established in 1868 and located in Berkeley, California, USA...

    . First distributed with BSD in 1978.
  • TENEX C shell (tcsh)
  • Hamilton C shell
    Hamilton C shell
    Hamilton C shell is a clone of the Unix C shell and utilities for Microsoft Windows created by Nicole Hamilton at Hamilton Laboratories. It was first released on OS/2 on December 12 1988 and on Windows NT in July 1992...

     written by Nicole Hamilton, first distributed on OS/2
    OS/2
    OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...

     in 1988 and on Windows since 1992.

Other or exotic

  • es
    Es shell
    The es shell is a command line interpreter developed by Byron Rakitzis and Paul Haahr, that uses a scripting language similar to the rc shell of the Plan 9 operating system. It is intended to provide a fully functional programming language as a Unix shell. The bulk of es' development occurred in...

    , a functional programming
    Functional programming
    In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

     rc-compatible shell written in the mid-1990s.
  • fish
    Friendly interactive shell
    The friendly interactive shell is a Unix shell that focuses on interactive use, discoverability, and user friendliness. The design goal of fish is to give the user a rich set of powerful features in a way that is easy to discover, remember, and use.Released in 2005 under the terms of the GNU...

     (friendly interactive shell), first released in 2005.
  • psh
    Perl Shell
    The Perl Shell is a command line environment that can be used as the user's primary post-login shell on Unix-like operating systems.Being itself written in Perl, psh can also be used under Microsoft Windows and other operating systems...

     (Perl
    Perl
    Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

     shell), a shell for Unix-like and Windows operating systems, combining aspects of bash (and other Unix shells) with the power of the Perl
    Perl
    Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

     scripting language.
  • pysh, a special profile of the IPython
    IPython
    IPython is an interactive shell for the Python programming language that offers enhanced introspection, additional shell syntax, tab completion and rich history.- Other features :...

     project, tries to integrate a heavily enhanced Python
    Python (programming language)
    Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

     shell and system shell into a seamless experience.
  • rc, the default shell on Plan 9 from Bell Labs
    Plan 9 from Bell Labs
    Plan 9 from Bell Labs is a distributed operating system. It was developed primarily for research purposes as the successor to Unix by the Computing Sciences Research Center at Bell Labs between the mid-1980s and 2002...

     and Version 10 Unix
    Version 10 Unix
    Tenth Edition Unix, also known as Version 10 Unix or V10, was the last version of the Research Unix operating system developed and used internally at Bell Labs. "Released" in 1989, it was the successor of V9...

     written by Tom Duff
    Tom Duff
    Thomas Douglas Selkirk Duff is a computer programmer. He was born in Toronto, Ontario, Canada and grew up in Toronto and Leaside. In 1974 he graduated from the University of Waterloo with a B.Math and, two years later, got an M.Sc...

    . Ports have been made to various Unix-like
    Unix-like
    A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

     operating systems.
  • scsh
    Scsh
    Scsh is a POSIX API layered on top of the Scheme programming language in a manner to make the most of Scheme's capability for scripting. It is limited to 32-bit platforms but there is a development version against the latest scheme48 that works in 64bit mode.....

    , a Scheme Shell.
  • wish, a windowing shell for Tcl/Tk.
  • zoidberg, a modular Perl shell written, configured, and operated entirely in Perl
    Perl
    Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

    .


A list of various shells may be found at www.freebsd.org.

Historic

  • Thompson shell
    Thompson shell
    The Thompson shell was the first Unix shell, introduced in the first version of Unix in 1971, and was written by Ken Thompson.It was a simple command interpreter, not designed for scripting, but nonetheless introduced several innovative features to the command line interface and led to the...

     (sh) -- The first Unix shell, written by Ken Thompson at Bell Labs
    Bell Labs
    Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

    . Distributed with Versions 1 through 6 of Unix, from 1971 to 1975. Considered very rudimentary by modern standards and not used on current systems, though available as part of some Ancient UNIX Systems
    Ancient UNIX Systems
    Ancient UNIX is a term coined by Santa Cruz Operation, to describe early releases of the Unix code base released prior to Unix System III, particularly the Research Unix releases prior to and including Version 7 .After the publication of the Lions' book, work was undertaken to release the earlier...

    .
  • PWB shell
    PWB shell
    The PWB shell was an early Unix shell.Distributed with some versions of Programmer's Workbench UNIX circa 1975-1977, it was a modified version of the Thompson shell with additional features to increase usability for programming, and was maintained by John Mashey and various others The PWB shell...

      or Mashey shell (sh) -- A version of the Thompson shell, augmented by John Mashey
    John Mashey
    John Mashey is a computer scientist, director and entrepreneur.Mashey holds a Ph.D. in computer science from Pennsylvania State University, where he developed the ASSIST assembler language teaching software. He worked on the PWB/UNIX operating system at Bell Labs from 1973 to 1983, authoring the...

     and others, while at Bell Labs
    Bell Labs
    Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

    . Distributed with the Programmer's Workbench UNIX, circa 1976.

Configuration files for shells

Shells read configuration files on multiple circumstances which differ depending on the shell. This table shows the configuration files for popular shells: /etc/.login
sh ksh csh tcsh bash zsh
login login
/etc/csh.cshrc yes yes
/etc/csh.login login login
~/.tcshrc yes
~/.cshrc yes yes
~/.login login login
~/.logout login login
/etc/profile login login login login
~/.profile login login login login
~/.bash_profile login
~/.bash_login login
~/.bash_logout login
~/.bashrc int.+n/login
/etc/zshenv yes
/etc/zprofile login
/etc/zshrc int.
/etc/zlogin login
/etc/zlogout login
~/.zshenv yes
~/.zprofile login
~/.zshrc int.
~/.zlogin 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.

See also

  • Comparison of command shells
  • List of Unix programs
  • Restricted shell
    Restricted shell
    The restricted shell is a Unix shell that restricts some of the capabilities available to an interactive user session, or to a shell script, running within it. It is intended to provide an additional layer of security, but is insufficient to allow execution of entirely untrusted software...

  • Shell (computing)
    Shell (computing)
    A shell is a piece of software that provides an interface for users of an operating system which provides access to the services of a kernel. However, the term is also applied very loosely to applications and may include any software that is "built around" a particular component, such as web...

  • Shell account
    Shell account
    A shell account is a user account on a remote server which gives access to a shell via a command-line interface protocol such as telnet or ssh....

  • Shell script
    Shell script
    A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language...

  • Shell shoveling
    Shell shoveling
    Shell shoveling, in network security, refers to the act of redirecting the input and output of a shell to a service so that it can be remotely accessed....


Further reading

— a history of the various shells, and the uses of and responsibilities of a shell on Unix

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK