Misplaced Pages

Unix shell

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

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 and a scripting language , and is used by the operating system to control the execution of the system using shell scripts .

#538461

39-490: 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 . Generally, a shell is a program that executes other programs in response to text commands. A sophisticated shell can also change

78-426: A child process to run the first command with its standard output piped back to the shell, which reads that output, parsing it into words separated by whitespace . Because the shell can't know it has all the output from the child until the pipe closes or the child dies, it waits until then before it starts another child process to run the second command. This C shell example shows how one might search for all

117-407: A shell or text terminal , the term terminal covers all remote terminals, including graphical interfaces. A terminal emulator inside a graphical user interface is often called a terminal window . A terminal window allows the user access to a text terminal and all its applications such as command-line interfaces (CLI) and text user interface (TUI) applications. These may be running either on

156-458: A graduate student at University of California, Berkeley , and was widely distributed with BSD Unix . 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 to TENEX C shell (tcsh), an improved version of Joy's original version. Although

195-431: A graphical interface. Virtual consoles are found on most Unix-like systems. They are primarily used to access and interact with servers, without using a graphical desktop environment. Command substitution In computing , command substitution is a facility that allows a command to be run and its output to be pasted back on the command line as arguments to another command. Command substitution first appeared in

234-409: A program can use, most easily via a library such as ncurses . For more complex operations, the programs can use console and terminal special ioctl system calls. One can compare devices using the patterns vcs ("virtual console screen") and vcsa ("virtual console screen with attributes") such as /dev/vcs1 and /dev/vcsa1 . Some terminal emulators also include escape sequences for configuring

273-503: A protocol controls who may send data when. IBM 3270 -based terminals used with IBM mainframe computers are an example of synchronous terminals . They operate in an essentially "screen-at-a-time" mode (also known as block mode ). Users can make numerous changes to a page, before submitting the updated screen to the remote machine as a single action. Terminal emulators that simulate the 3270 protocol are available for most operating systems, for use both by those administering systems such as

312-505: A space, that filename will be broken into two separate arguments to vi , clearly not what was intended. Hamilton C shell solved this with a double backquote notation, ``  ...  `` , that parses into words only at line breaks. This is an example of command substitution using the () operator in PowerShell : A related facility, expression substitution, is found in the languages Common Lisp and Scheme , invoked by using

351-500: A strict subset of the Korn shell , 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 ( $ ). 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

390-443: Is a type of computer terminal that communicates with its host one character at a time, as opposed to a block-oriented terminal that communicates in blocks of data. It is the most common type of data terminal, because it is easy to implement and program. Connection to the mainframe computer or terminal server is achieved via RS-232 serial links, Ethernet or other proprietary protocols . When personal computers became ubiquitous in

429-416: Is typically stored in the user's profile, for example in the local passwd file or in a distributed configuration system such as NIS 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 distributions , some users may never use the shell directly. On Unix systems, the shell has historically been

SECTION 10

#1732852825539

468-574: The Bourne shell , introduced with Version 7 Unix in 1979, and has remained a characteristic of all later Unix shells . The feature has since been adopted in other programming languages as well, including Perl , PHP , Ruby and Microsoft's Powershell under Windows . It also appears in Microsoft's CMD.EXE in the FOR command and the ( ) command. Shells typically implement command substitution by creating

507-480: The C files containing the string malloc using fgrep and then edit any that are found using the vi editor. The syntactical notation shown here, `  ...  ` , using backquotes as delimiters , is the original style and is supported by all the common Unix shells. Objections have been raised to both the syntax , how it's typed, and the semantics , how it works. While easy to type, an important factor for an interactive command processor,

546-823: The RUNCOM 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 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

585-506: The z9 , as well as those using the corresponding applications such as CICS . Other examples of synchronous terminals include the IBM 5250 , ICL 7561, Honeywell Bull VIP7800 and Hewlett-Packard 700/92. Virtual consoles , also called virtual terminals, are emulated text terminals , using the keyboard and monitor of a personal computer or workstation. The word "text" is key since virtual consoles are not GUI terminals and they do not run inside

624-399: The 1980s, they offered the option of running software on the user's personal computer, providing an opportunity to replace the expensive and space consuming hardware terminals with something that had additional functions. Immediately software became available, that could emulate the functions of the hardware terminals on a PC. Examples of such software for DOS were Telix or Telemate, which

663-410: The 1990s, new operating systems like Windows and OS/2 arrived, providing the technical background for more terminal emulators like Telix for Windows , ZOC for OS/2 , or PuTTY , which was initially released for Windows in 1998 and which (together with its derivates) is still one a very popular choice to this day. Through the success of Linux , especially running on data centers and cloud servers,

702-450: 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 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

741-500: The behavior and appearance of the shell. The table in this section shows the configuration files for popular shells. Explanation: Variations on the Unix shell concept that don't derive from Bourne shell or C shell include the following: Terminal emulator A terminal emulator , or terminal application , is a computer program that emulates a video terminal within some other display architecture. Though typically synonymous with

780-589: The behavior of the terminal to facilitate good interoperation between the terminal and programs running inside of it, for example to configure paste bracketing . The virtual consoles can be configured in the file /etc/inittab read by init —typically it starts the text mode login process getty for several virtual consoles. X Window System can be configured in /etc/inittab or by an X display manager . A number of Linux distributions use systemd instead of init , which also allows virtual console configuration. Typical Linux system programs used to access

819-570: The early Unix shells were the Bourne shell 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. The Bourne shell , 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

SECTION 20

#1732852825539

858-462: The early days of computing, with the advent of interactive computing, the prevailing model involved a central computer connected to multiple terminals. This configuration, known as the centralized or mainframe model, featured a powerful central computer that performed all the processing tasks, while terminals served as input/output devices for users to interact with the system. These systems were initially character based. A character-oriented terminal

897-590: The emulated terminal. Additionally, programs have been developed to emulate assorted system console "terminals" such as the Sun workstation console and the Linux console . Finally, some emulators simply refer to a set of standards, such as the standards for ANSI escape codes . Such programs are available on many platforms, including DOS , Unix-like systems including Linux and macOS , Windows , and embedded operating systems found in cellphones and industrial hardware. In

936-421: 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,

975-587: 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 ) with different approaches, such as systemd . 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

1014-512: 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 , written by Nicole Hamilton, first distributed on OS/2 in 1988 and on Windows since 1992. 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 , and others that control

1053-475: The line-at-a-time mode option in the telnet protocol. To implement it correctly, the Network Virtual Terminal implementation provided by the terminal emulator program must be capable of recognizing and properly dealing with "interrupt" and "abort" events that arrive in the middle of locally editing a line. In asynchronous terminals data can flow in any direction at any time. In synchronous terminals

1092-433: The master side) and /dev/ttyp0 (for the slave side) pseudoterminal devices respectively. There are also special virtual console files like /dev/console . In text mode, writing to the file displays text on the virtual console and reading from the file returns text the user writes to the virtual console. As with other text terminals , there are also special escape sequences , control characters and functions that

1131-720: The necessity of accessing remote computers through character based terminals remains. This is evident in the fact, that today lists of terminal emulators that could serve as alternative to the aforementioned PuTTY offers over 100 alternatives. Many terminal emulators have been developed for physical hardware terminals such as VT52 , VT100 , VT220 , VT320 , IBM 3270/8/9/E , IBM 5250 , IBM 3179G , Data General D211, Hewlett-Packard HP700/92, Sperry/Unisys 2000-series UTS60 , Burroughs/Unisys A-series T27/TD830/ET1100, ADDS ViewPoint, AT386, Siemens Nixdorf (SNI) 97801, Televideo 925, and Wyse 50/60. Some terminal emulators, such as xterm , implement additional features not present in

1170-563: The past, Unix and Unix-like systems used serial port devices such as RS-232 ports, and provided /dev/* device files for them. With terminal emulators those device files are emulated by using a pair of pseudoterminal devices. This pair is used to emulate a physical port/connection to the host computing endpoint - computer's hardware provided by operating system APIs, some other software like rlogin , telnet or SSH or else. For example, in Linux systems these would be /dev/ptyp0 (for

1209-458: The same machine or on a different one via telnet , ssh , dial-up , or over a direct serial connection . On Unix-like operating systems, it is common to have one or more terminal windows connected to the local machine. Terminals usually support a set of escape sequences for controlling color, cursor position, etc. Examples include the family of terminal control sequence standards that includes ECMA-48 , ANSI X3.64 , and ISO/IEC 6429 . In

Unix shell - Misplaced Pages Continue

1248-412: The same semantics. The semantics, breaking the output into words at whitespace, has also been criticized. It worked well on early Unix systems where filenames never contained spaces but it doesn't work at all well on modern Windows and Linux systems where filenames certainly can contain spaces. In either of these previous examples, if any of the filenames matched by the *.c wildcard contains

1287-403: 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

1326-426: The syntax has been criticized as awkward to nest, putting one command substitution inside another, because both the left and the right delimiters are the same. The KornShell (ksh) solved this with an alternative notation, $ (  ...  ) , borrowing from the notational style used for variable substitution . Today, most UNIX shells support this syntax. Microsoft's PowerShell also uses this notation, with

1365-454: The terminal emulator only sends complete lines of input to the host system. The user enters and edits a line, but it is held locally within the terminal emulator as it is being edited. It is not transmitted until the user signals its completion, usually with the ↵ Enter key on the keyboard or a "send" button of some sort in the user interface. At that point, the entire line is transmitted. Line-at-a-time mode implies local echo, since otherwise

1404-462: 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 sh and its path in the Unix file system hierarchy is /bin/sh . 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 to one of these alternatives: The POSIX standard specifies its standard shell as

1443-402: The user will not be able to see the line as it is being edited and constructed. However, line-at-a-time mode is independent of echo mode and does not require local echo. When entering a password, for example, line-at-a-time entry with local editing is possible, but local echo is turned off (otherwise the password would be displayed). The complexities of line-at-a-time mode are exemplified by

1482-430: The virtual consoles include: Terminal emulators may implement a local echo function, which may erroneously be named " half-duplex ", or still slightly incorrectly "echoplex" (which is formally an error detection mechanism rather than an input display option). Terminal emulators may implement local editing, also known as "line-at-a-time mode". This is also mistakenly referred to as " half-duplex ". In this mode,

1521-537: Was published in 1988 and could emulate a DEC VT102 terminal. Workstations , usually running versions of Unix , also became common in the 1980s. Unix systems usually provided access to the command line with locally-attached or dial-up terminals. Unix workstations were designed to be used primarily through a graphical user interface (GUI); to provide access to the command line, the GUI included terminal emulator applications that behaved like locally-attached terminals. During

#538461