Unix shell

From Wikipedia for FEVERv2
Jump to navigation Jump to search

A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. Unix shell_sentence_0

The shell is both an interactive command language and a scripting language, and is used by the operating system to control the execution of the system using shell scripts. Unix shell_sentence_1

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. Unix shell_sentence_2

All Unix shells provide filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. Unix shell_sentence_3

Concept Unix shell_section_0

The most generic sense of the term shell means any program that users employ to type commands. Unix shell_sentence_4

A shell hides the details of the underlying operating system and manages the technical details of the operating system kernel interface, which is the lowest-level, or "inner-most" component of most operating systems. Unix shell_sentence_5

In Unix-like operating systems, users typically have many choices of command-line interpreters for interactive sessions. Unix shell_sentence_6

When a user logs into the system interactively, a shell program is automatically executed for the duration of the session. Unix shell_sentence_7

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 or LDAP; however, the user may execute any other available shell interactively. Unix shell_sentence_8

On hosts with a windowing system, like macOS, some users may never use the shell directly. Unix shell_sentence_9

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. Unix shell_sentence_10

However, some system vendors have replaced the traditional shell-based startup system (init) with different approaches, such as systemd. Unix shell_sentence_11

Early shells Unix shell_section_1

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. Unix shell_sentence_12

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. Unix shell_sentence_13

Though not in current use, it is still available as part of some Ancient UNIX Systems. Unix shell_sentence_14

It was modeled after the Multics shell, developed in 1965 by American software engineer Glenda Schroeder. Unix shell_sentence_15

Schroeder's Multics shell was itself modeled after the RUNCOM program Louis Pouzin showed to the Multics Team. Unix shell_sentence_16

The "rc" suffix on some Unix configuration files (for example, ".vimrc"), is a remnant of the RUNCOM ancestry of Unix shells. Unix shell_sentence_17

The PWB shell 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. Unix shell_sentence_18

It focused on making shell programming practical, especially in large shared computing centers. Unix shell_sentence_19

It added shell variables (precursors of environment variables, including the search path mechanism that evolved into $PATH), user-executable shell scripts, and interrupt-handling. Unix shell_sentence_20

Control structures were extended from if/goto to if/then/else/endif, switch/breaksw/endsw, and while/end/break/continue. Unix shell_sentence_21

As shell programming became widespread, these external commands were incorporated into the shell itself for performance. Unix shell_sentence_22

But the most widely distributed and influential of the early Unix shells were the Bourne shell and the C shell. Unix shell_sentence_23

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

Bourne shell Unix shell_section_2

The Bourne shell, sh, was a new Unix shell by Stephen Bourne at Bell Labs. Unix shell_sentence_25

Distributed as the shell for UNIX Version 7 in 1979, it introduced the rest of the basic features considered common to all the Unix shells, including here documents, command substitution, more generic variables and more extensive builtin control structures. Unix shell_sentence_26

The language, including the use of a reversed keyword to mark the end of a block, was influenced by ALGOL 68. Unix shell_sentence_27

Traditionally, the Bourne shell program name is sh and its path in the Unix file system hierarchy is /bin/sh. Unix shell_sentence_28

But a number of compatible work-alikes are also available with various improvements and additional features. Unix shell_sentence_29

On many systems, sh may be a symbolic link or hard link to one of these alternatives: Unix shell_sentence_30

Unix shell_unordered_list_0

  • 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.Unix shell_item_0_0
  • 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.Unix shell_item_0_1
  • Debian Almquist shell (dash): a modern replacement for ash in Debian and UbuntuUnix shell_item_0_2
  • KornShell (ksh): written by David Korn based on the Bourne shell sources while working at Bell LabsUnix shell_item_0_3
  • Public domain Korn shell (pdksh)Unix shell_item_0_4
  • MirBSD Korn shell (mksh): a descendant of the OpenBSD /bin/ksh and pdksh, developed as part of MirOS BSDUnix shell_item_0_5
  • Z shell (zsh): a relatively modern shell that is backward compatible with bash. It's the default shell in macOS since 10.15 Catalina.Unix shell_item_0_6
  • 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.Unix shell_item_0_7

The POSIX standard specifies its standard shell as a strict subset of the Korn shell, an enhanced version of the Bourne shell. Unix shell_sentence_31

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

C shell Unix shell_section_3

The C shell, csh, was modeled on the C programming language, including the control structures and the expression grammar. Unix shell_sentence_33

It was written by Bill Joy as a graduate student at University of California, Berkeley, and was widely distributed with BSD Unix. Unix shell_sentence_34

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. Unix shell_sentence_35

On many systems, csh may be a symbolic link or hard link to TENEX C shell (tcsh), an improved version of Joy's original version. Unix shell_sentence_36

Although the interactive features of csh have been copied to most other shells, the language structure has not been widely copied. Unix shell_sentence_37

The only work-alike is Hamilton C shell, written by Nicole Hamilton, first distributed on OS/2 in 1988 and on Windows since 1992. Unix shell_sentence_38

Configuration files Unix shell_section_4

Shells read configuration files in various circumstances. Unix shell_sentence_39

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, and others that control the behavior and appearance of the shell. Unix shell_sentence_40

The table in this section shows the configuration files for popular shells. Unix shell_sentence_41

Unix shell_table_general_0

Unix shell_cell_0_0_0 shUnix shell_header_cell_0_0_1 kshUnix shell_header_cell_0_0_2 cshUnix shell_header_cell_0_0_3 tcshUnix shell_header_cell_0_0_4 bashUnix shell_header_cell_0_0_5 zshUnix shell_header_cell_0_0_6
/etc/.loginUnix shell_cell_0_1_0 Unix shell_cell_0_1_1 Unix shell_cell_0_1_2 loginUnix shell_cell_0_1_3 loginUnix shell_cell_0_1_4 Unix shell_cell_0_1_5 Unix shell_cell_0_1_6
/etc/csh.cshrcUnix shell_cell_0_2_0 Unix shell_cell_0_2_1 Unix shell_cell_0_2_2 yesUnix shell_cell_0_2_3 yesUnix shell_cell_0_2_4 Unix shell_cell_0_2_5 Unix shell_cell_0_2_6
/etc/csh.loginUnix shell_cell_0_3_0 Unix shell_cell_0_3_1 Unix shell_cell_0_3_2 loginUnix shell_cell_0_3_3 loginUnix shell_cell_0_3_4 Unix shell_cell_0_3_5 Unix shell_cell_0_3_6
~/.tcshrcUnix shell_cell_0_4_0 Unix shell_cell_0_4_1 Unix shell_cell_0_4_2 Unix shell_cell_0_4_3 yesUnix shell_cell_0_4_4 Unix shell_cell_0_4_5 Unix shell_cell_0_4_6
~/.cshrcUnix shell_cell_0_5_0 Unix shell_cell_0_5_1 Unix shell_cell_0_5_2 yesUnix shell_cell_0_5_3 yesUnix shell_cell_0_5_4 Unix shell_cell_0_5_5 Unix shell_cell_0_5_6
~/etc/ksh.kshrcUnix shell_cell_0_6_0 Unix shell_cell_0_6_1 int.Unix shell_cell_0_6_2 Unix shell_cell_0_6_3 Unix shell_cell_0_6_4 Unix shell_cell_0_6_5 Unix shell_cell_0_6_6
/etc/sh.shrcUnix shell_cell_0_7_0 int.Unix shell_cell_0_7_1 Unix shell_cell_0_7_2 Unix shell_cell_0_7_3 Unix shell_cell_0_7_4 Unix shell_cell_0_7_5 Unix shell_cell_0_7_6
$ENV (typically ~/.kshrc)Unix shell_cell_0_8_0 int.Unix shell_cell_0_8_1 int.Unix shell_cell_0_8_2 Unix shell_cell_0_8_3 Unix shell_cell_0_8_4 int.Unix shell_cell_0_8_5 Unix shell_cell_0_8_6
~/.loginUnix shell_cell_0_9_0 Unix shell_cell_0_9_1 Unix shell_cell_0_9_2 loginUnix shell_cell_0_9_3 loginUnix shell_cell_0_9_4 Unix shell_cell_0_9_5 Unix shell_cell_0_9_6
~/.logoutUnix shell_cell_0_10_0 Unix shell_cell_0_10_1 Unix shell_cell_0_10_2 loginUnix shell_cell_0_10_3 loginUnix shell_cell_0_10_4 Unix shell_cell_0_10_5 Unix shell_cell_0_10_6
/etc/profileUnix shell_cell_0_11_0 loginUnix shell_cell_0_11_1 loginUnix shell_cell_0_11_2 Unix shell_cell_0_11_3 Unix shell_cell_0_11_4 loginUnix shell_cell_0_11_5 loginUnix shell_cell_0_11_6
~/.profileUnix shell_cell_0_12_0 loginUnix shell_cell_0_12_1 loginUnix shell_cell_0_12_2 Unix shell_cell_0_12_3 Unix shell_cell_0_12_4 loginUnix shell_cell_0_12_5 loginUnix shell_cell_0_12_6
~/.bash_profileUnix shell_cell_0_13_0 Unix shell_cell_0_13_1 Unix shell_cell_0_13_2 Unix shell_cell_0_13_3 Unix shell_cell_0_13_4 loginUnix shell_cell_0_13_5 Unix shell_cell_0_13_6
~/.bash_loginUnix shell_cell_0_14_0 Unix shell_cell_0_14_1 Unix shell_cell_0_14_2 Unix shell_cell_0_14_3 Unix shell_cell_0_14_4 loginUnix shell_cell_0_14_5 Unix shell_cell_0_14_6
~/.bash_logoutUnix shell_cell_0_15_0 Unix shell_cell_0_15_1 Unix shell_cell_0_15_2 Unix shell_cell_0_15_3 Unix shell_cell_0_15_4 loginUnix shell_cell_0_15_5 Unix shell_cell_0_15_6
~/.bashrcUnix shell_cell_0_16_0 Unix shell_cell_0_16_1 Unix shell_cell_0_16_2 Unix shell_cell_0_16_3 Unix shell_cell_0_16_4 int.+n/loginUnix shell_cell_0_16_5 Unix shell_cell_0_16_6
/etc/zshenvUnix shell_cell_0_17_0 Unix shell_cell_0_17_1 Unix shell_cell_0_17_2 Unix shell_cell_0_17_3 Unix shell_cell_0_17_4 Unix shell_cell_0_17_5 yesUnix shell_cell_0_17_6
/etc/zprofileUnix shell_cell_0_18_0 Unix shell_cell_0_18_1 Unix shell_cell_0_18_2 Unix shell_cell_0_18_3 Unix shell_cell_0_18_4 Unix shell_cell_0_18_5 loginUnix shell_cell_0_18_6
/etc/zshrcUnix shell_cell_0_19_0 Unix shell_cell_0_19_1 Unix shell_cell_0_19_2 Unix shell_cell_0_19_3 Unix shell_cell_0_19_4 Unix shell_cell_0_19_5 int.Unix shell_cell_0_19_6
/etc/zloginUnix shell_cell_0_20_0 Unix shell_cell_0_20_1 Unix shell_cell_0_20_2 Unix shell_cell_0_20_3 Unix shell_cell_0_20_4 Unix shell_cell_0_20_5 loginUnix shell_cell_0_20_6
/etc/zlogoutUnix shell_cell_0_21_0 Unix shell_cell_0_21_1 Unix shell_cell_0_21_2 Unix shell_cell_0_21_3 Unix shell_cell_0_21_4 Unix shell_cell_0_21_5 loginUnix shell_cell_0_21_6
~/.zshenvUnix shell_cell_0_22_0 Unix shell_cell_0_22_1 Unix shell_cell_0_22_2 Unix shell_cell_0_22_3 Unix shell_cell_0_22_4 Unix shell_cell_0_22_5 yesUnix shell_cell_0_22_6
~/.zprofileUnix shell_cell_0_23_0 Unix shell_cell_0_23_1 Unix shell_cell_0_23_2 Unix shell_cell_0_23_3 Unix shell_cell_0_23_4 Unix shell_cell_0_23_5 loginUnix shell_cell_0_23_6
~/.zshrcUnix shell_cell_0_24_0 Unix shell_cell_0_24_1 Unix shell_cell_0_24_2 Unix shell_cell_0_24_3 Unix shell_cell_0_24_4 Unix shell_cell_0_24_5 int.Unix shell_cell_0_24_6
~/.zloginUnix shell_cell_0_25_0 Unix shell_cell_0_25_1 Unix shell_cell_0_25_2 Unix shell_cell_0_25_3 Unix shell_cell_0_25_4 Unix shell_cell_0_25_5 loginUnix shell_cell_0_25_6

Explanation: Unix shell_sentence_42

Unix shell_unordered_list_1

  • blank means a file is not read by a shell at all.Unix shell_item_1_8
  • "yes" means a file is always read by a shell upon startup.Unix shell_item_1_9
  • "login" means a file is read if the shell is a login shell.Unix shell_item_1_10
  • "n/login" means a file is read if the shell is not a login shell.Unix shell_item_1_11
  • "int." means a file is read if the shell is interactive.Unix shell_item_1_12

Other shells Unix shell_section_5

Variations on the Unix shell concept that don't derive from Bourne shell or C shell include the following: Unix shell_sentence_43

Unix shell_unordered_list_2

See also Unix shell_section_6

Credits to the contents of this page go to the authors of the corresponding Wikipedia page: en.wikipedia.org/wiki/Unix shell.