Unix shell

From Wikipedia, the free encyclopedia

  (Redirected from UNIX shell)
Jump to: navigation, search
Screenshot of a sample Bash session.

A Unix shell is a command-line interpreter (see shell) and script host that provides a 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 or by creating text scripts of one or more such commands.

The most prominent Unix shells are the Bourne shell, which is the original Unix command line interpreter for system control and user sessions, and the C shell, a shell primarily used for interactive user sessions in the line of Unix-derived operating systems based on the Berkeley Software Distribution (BSD). Both shells have been used as coding base and model for many derivative and work-alike shells with extended feature sets.

Contents

[edit] Concept

The most generic sense of the term shell means any program that users employ to type commands. In the Unix operating system users may select which shell to use for interactive sessions. When the user logs in to the system the shell program is automatically executed. Many types of shells have been developed for this purpose. The program is called a "shell" because it hides the details of the underlying operating system behind the shell's interface. The shell manages the technical details of the operating system kernel interface, which is 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, though in practice this usually requires administrator rights.

The Unix shell was unusual when it was first created. Since it is both an interactive command language as well as a scripting programming language it is used by Unix as the facility to control (see shell script) the execution of the system.

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.

Many users of a Unix system still find a modern command line shell more convenient for many tasks than any GUI application.

Due to the recent movement in favor of free and open source software, most Unix shells have at least one version that is distributed under an open source or free software license.

[edit] 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 and was first distributed with Version 7 Unix, 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 or hard link to a compatible, but more feature-rich shell than the Bourne shell. 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 ($).

[edit] C shell

The C shell was developed by Bill Joy 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). 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.

[edit] Shell categories

Unix shells can be broadly divided into four categories: Bourne-like, C shell-like, nontraditional, and historical.[citation needed]

[edit] 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.
  • Korn shell (ksh) -- Written by David Korn, while at Bell Labs.
  • Z shell (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.[citation needed]
  • Busybox -- Tiny utilities for small and embedded systems, include a shell.

[edit] C shell compatible

[edit] Other or exotic

  • fish (friendly interactive shell), first released in 2005.
  • mudsh, an "intelligent" game-like shell that operates like a MUD.
  • zoidberg, a modular Perl shell written, configured, and operated entirely in Perl.
  • pysh, an special profile of the ipython project, tries to integrate a heavily enhanced python shell and system shell into a seamless experience.
  • rc, the default shell on Plan 9 from Bell Labs and Version 10 Unix written by Tom Duff. Ports have been made to Inferno and Unix-like operating systems.
  • scsh (Scheme Shell)
  • wish, a windowing shell for Tcl/Tk

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

[edit] 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:

sh ksh csh tcsh bash zsh
/etc/.login login login
/etc/csh.cshrc yes yes
/etc/csh.login login login
~/.tcshrc yes
~/.cshrc yes yes[1]
~/.login login login
~/.logout login login
/etc/profile login login i.login
~/.profile login login login
~/.bash_profile login
~/.bash_login login
~/.bash_logout login
~/.bashrc 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
  1. ^ only if ~/.tcshrc not found

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.
  • "i.login" means a file is read if the shell is an interactive login shell.

[edit] Historic

[edit] See also

[edit] Further reading

  • Ellie Quigley (2001). "Introduction to UNIX shells". Unix Shells by Example. Prentice Hall PTR. ISBN 013066538X.  — a history of the various shells, and the uses of and responsibilities of a shell on Unix

[edit] External links