
A Unix shell is a command-line
interpreter or
shell that provides a command line
user interface for
Unix-like operating systems. The shell is both an interactive
command language
A command language is a language for job control (computing), job control in computing. It is a domain-specific language, domain-specific and interpreted language; common examples of a command language are shell script, shell or batch programming ...
and a
scripting language, and is used by the operating system to control the execution of the system using
shell script
A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manip ...
s.
Users typically interact with a Unix shell using a
terminal emulator; however, direct operation via serial hardware connections or
Secure Shell are common for server systems. All Unix shells provide filename
wildcarding,
piping,
here documents,
command substitution,
variables and
control structures for
condition-testing and
iteration.
Concept
Generally, a ''shell'' is a program that executes other programs in response to text commands. A sophisticated shell can also change the environment in which other programs execute by passing
named variables, a parameter list, or an input source.
In Unix-like operating systems, users typically have many choices of command-line interpreters for interactive sessions. When a user
logs into the system interactively, a shell program is automatically executed for the duration of the session. The type of shell, which may be customized for each user, is typically stored in the user's profile, for example in the local file or in a distributed configuration system such as
NIS
Nis, Niš, NiS or NIS may refer to:
Places
* Niš, a city in Serbia
* Nis, Iran, a village
* Ness, Lewis ( gd, Nis, links=no), a village in the Outer Hebrides islands
Businesses and organizations
* Naftna Industrija Srbije, Petroleum Industry of ...
or
LDAP; however, the user may execute any other available shell interactively.
On operating systems with a
windowing system, such as
macOS and desktop
Linux distribution
A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and, often, a package management system. Linux users usually obtain their operating system by downloading one ...
s, some users may never use the shell directly. On Unix systems, the shell has historically been the implementation language of system startup scripts, including the program that starts a windowing system, configures networking, and many other essential functions. However, some system vendors have replaced the traditional shell-based startup system (
init
In Unix-based computer operating systems, init (short for ''initialization'') is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direct ...
) with different approaches, such as
systemd
systemd is a software suite that provides an array of system components for Linux operating systems. Its main aim is to unify service configuration and behavior across Linux distributions; Its primary component is a "system and service manager ...
.
Early shells
The first Unix shell was the
Thompson shell, ''sh'', written by
Ken Thompson at
Bell Labs and distributed with Versions 1 through 6 of Unix, from 1971 to 1975.
Though rudimentary by modern standards, it introduced many of the basic features common to all later Unix shells, including piping, simple control structures using
if
and
goto
, and filename wildcarding. Though not in current use, it is still available as part of some
Ancient UNIX
Ancient UNIX is any early release of the Unix code base prior to Unix System III, particularly the Research Unix releases prior to and including Version 7 (the base for UNIX/32V as well as later developments of AT&T Unix).
After the publicati ...
systems.
It was modeled after the
Multics shell, developed in 1965 by American software engineer
Glenda Schroeder. Schroeder's Multics shell was itself modeled after the
RUNCOM
RUNCOM is a CTSS macro command (script) processor.
History
Louis Pouzin created RUNCOM for CTSS circa 1963. He wrote a paper in 1965 describing a design for the Multics shell which includes a brief description of RUNCOM followed by a second p ...
program
Louis Pouzin showed to the Multics Team. The "rc" suffix on some Unix configuration files (for example, ".vimrc"), is a remnant of the RUNCOM ancestry of Unix shells.
The
PWB shell
The PWB shell (also known as the Mashey shell) was a Unix shell.
History
The PWB shell was a modified (and generally constrained to be upward-compatible) version of the Thompson shell with additional features to increase usability for programmin ...
or Mashey shell, ''sh'', was an upward-compatible version of the Thompson shell, augmented by
John Mashey and others and distributed with the
Programmer's Workbench UNIX, circa 1975–1977. It focused on making shell programming practical, especially in large shared computing centers. It added shell variables (precursors of
environment variables, including the search path mechanism that evolved into $PATH), user-executable shell scripts, and interrupt-handling. Control structures were extended from if/goto to if/then/else/endif, switch/breaksw/endsw, and while/end/break/continue. As shell programming became widespread, these external commands were incorporated into the shell itself for performance.
But the most widely distributed and influential of the early Unix shells were the
Bourne shell
The Bourne shell (sh) is a Shell (computing), shell Command-line interface#Command-line interpreter, command-line interpreter for computer operating systems.
The Bourne shell was the default Unix shell, shell for Version 7 Unix. Unix-like syste ...
and the
C shell. Both shells have been used as the coding base and model for many derivative and work-alike shells with extended feature sets.
Bourne shell
The
Bourne shell
The Bourne shell (sh) is a Shell (computing), shell Command-line interface#Command-line interpreter, command-line interpreter for computer operating systems.
The Bourne shell was the default Unix shell, shell for Version 7 Unix. Unix-like syste ...
, ''sh'', was a new Unix shell by
Stephen Bourne at Bell Labs. Distributed as the shell for UNIX Version 7 in 1979, it introduced the rest of the basic features considered common to all the later Unix shells, including
here documents,
command substitution, more generic
variables and more extensive builtin
control structures. The language, including the use of a reversed keyword to mark the end of a block, was influenced by
ALGOL 68. Traditionally, the Bourne shell program name is and its path in the Unix file system hierarchy is . 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
In computing, a hard link is a directory entry (in a directory-based file system) that associates a name with a file. Thus, each file must have at least one hard link. Creating additional hard links for a file makes the contents of that file acc ...
to one of these alternatives:
*
Almquist shell
Almquist shell (also known as A Shell, ash and sh) is a lightweight Unix shell originally written by Kenneth Almquist in the late 1980s. Initially a clone of the System V.4 variant of the Bourne shell, it replaced the original Bourne shell in the ...
(ash): written as a BSD-licensed replacement for the Bourne Shell; often used in resource-constrained environments. The sh of
FreeBSD
FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
,
NetBSD
NetBSD is a free and open-source Unix operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was forked. It continues to be actively developed and is a ...
(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
Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of D ...
and
Ubuntu
*
Bourne-Again shell
Bash is a Unix shell and command language written by Brian Fox (computer programmer), Brian Fox for the GNU Project as a free software replacement for the Bourne shell. First released in 1989, it has been used as the default login shell for most ...
(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.
*
KornShell
KornShell (ksh) is a Unix shell which was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983. The initial development was based on Bourne shell source code. Other early contributors were Bell ...
(ksh): written by
David Korn based on the Bourne shell sources while working at
Bell Labs
*
Public domain Korn shell (pdksh)
**
MirBSD Korn shell (mksh): a descendant of the
OpenBSD
OpenBSD is a security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by forking NetBSD 1.0. According to the website, the OpenBSD project em ...
/bin/ksh and pdksh, developed as part of
MirOS BSD
MirOS BSD (originally called MirBSD) is a free and open source operating system which started as a fork of OpenBSD 3.1 in August 2002. It was intended to maintain the security of OpenBSD with better support for European localisation. Since then ...
*
Z shell (zsh): a relatively modern shell that is
backward compatible with
bash
Bash or BASH may refer to:
Arts and entertainment
* ''Bash!'' (Rockapella album), 1992
* ''Bash!'' (Dave Bailey album), 1961
* '' Bash: Latter-Day Plays'', a dramatic triptych
* ''BASH!'' (role-playing game), a 2005 superhero game
* "Bash" ('' ...
. It's the default shell in
Kali Linux since 2020.4 and
macOS since 10.15
Catalina
Catalina may refer to:
Arts and media
* ''The Catalina'', a 2012 American reality television show
* ''Catalina'' (novel), a 1948 novel by W. Somerset Maugham
* Catalina (''My Name Is Earl''), character from the NBC sitcom ''My Name Is Earl''
...
.
The
POSIX standard specifies its standard shell as a strict subset of the
Korn shell
KornShell (ksh) is a Unix shell which was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983. The initial development was based on Bourne shell source code. Other early contributors were Bell L ...
, an enhanced version of the Bourne 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 ().
C shell
The
C shell, ''csh'', was modeled on the C programming language, including the control structures and the expression grammar. It was written by
Bill Joy as a graduate student at
University of California, Berkeley, and was widely distributed with
BSD Unix
The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berk ...
.
The C shell also introduced many features for interactive work, including the
history and
editing mechanisms,
aliases,
directory stacks,
tilde notation,
cdpath,
job control and
path hashing. On many systems, csh may be a
symbolic link or
hard link
In computing, a hard link is a directory entry (in a directory-based file system) that associates a name with a file. Thus, each file must have at least one hard link. Creating additional hard links for a file makes the contents of that file acc ...
to
TENEX C shell
tcsh ( “tee-see-shell”, “tee-shell”, or as “tee see ess aitch”, tcsh) is a Unix shell
A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shel ...
(tcsh), an improved version of Joy's original version. Although the interactive features of csh have been copied to most other shells, the language structure has not been widely copied. The only work-alike is
Hamilton C shell
Hamilton C shell is a clone of the Unix C shell and utilities
Early
for Microsoft Windows created by Nicole Hamilton at Hamilton Laboratories as a completely original work, not based on any prior code. It was first released on OS/2 on Dece ...
, written by Nicole Hamilton, first distributed on
OS/2 in 1988 and on
Windows since 1992.
Configuration files
Shells read configuration files in various circumstances. These files usually contain commands for the shell and are executed when loaded; they are usually used to set important variables used to find executables, like
$PATH
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.
...
, and others that control the behavior and appearance of the shell. The table in this section shows the configuration files for popular shells.
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.
Other shells
Variations on the Unix shell concept that don't derive from Bourne shell or C shell include the following:
*
es – A
functional programming rc-compatible shell written in the mid-1990s.
*
Friendly interactive shell
fish is a Unix shell with a focus on interactivity and usability. Fish is designed to give the user features by default, rather than by configuration. Fish is considered an exotic shell since it does not rigorously adhere to POSIX shell standar ...
(fish) – First released in 2005.
*
PowerShell – An
object-oriented shell developed originally for Windows OS and now available to macOS and Linux.
*
Qshell
Qshell is an optional command-line interpreter (shell (computing), shell) for the IBM i, IBM i operating system. Qshell is based on POSIX and X/Open standards. It is a Bourne shell, Bourne-like shell that also includes features of KornShell. The u ...
– A shell on the
IBM i
IBM i (the ''i'' standing for ''integrated'') is an operating system developed by IBM for IBM Power Systems. It was originally released in 1988 as OS/400, as the sole operating system of the IBM AS/400 line of systems. It was renamed to i5/OS in ...
operating system based on
POSIX and
X/Open standards.
*
rc – The default shell on
Plan 9 from Bell Labs and
Version 10 Unix
The term "Research Unix" refers to early versions of the Unix operating system for DEC PDP-7, PDP-11, VAX and Interdata 7/32 and 8/32 computers, developed in the Bell Labs Computing Sciences Research Center (CSRC).
History
The term ''Researc ...
written by
Tom Duff
Tom or TOM may refer to:
* Tom (given name), a diminutive of Thomas or Tomás or an independent Aramaic given name (and a list of people with the name)
Characters
* Tom Anderson, a character in ''Beavis and Butt-Head''
* Tom Beck, a character ...
. Ports have been made to various
Unix-like operating systems.
*
scsh
Scsh (a ''Scheme shell'') is computer software, a type of shell for an operating system. It is a Portable Operating System Interface (POSIX) application programming interface (API) layered on the programming language Scheme, in a manner to make ...
– A
Scheme A scheme is a systematic plan for the implementation of a certain idea.
Scheme or schemer may refer to:
Arts and entertainment
* ''The Scheme'' (TV series), a BBC Scotland documentary series
* The Scheme (band), an English pop band
* ''The Schem ...
Shell.
*
wish – A windowing shell for
Tcl/Tk.
See also
References
{{Unix
System administration