Shell
Shell is a program with special functions. It is an interface between the user and the core program (kernel) of the Unix/Linux operating system. Why do we say shell is an intermediary between the core program of the system and the user? Readers who have read the introduction to the operating system know that the operating system is a manager and distributor of system resources. When you have requirements, you must submit them to the system. From the operating system perspective, it must also prevent system damage caused by incorrect operations? As we all know, commands on a computer can be converted into binary code through command or program. What about commands? In fact, shell is also a program that reads commands from the input device, converts them into mechanical codes that computers can understand, and then executes them.
Various operating systems have their own shells. For example, in DOS, the shell is command.com commands. For example, different command interpreter programs such as ndos, 4dos, and drdos in DOS can replace the standard command.com, except for the Bourne shell (/bin/sh) in UNIX) c shell (/bin/CSH), KoRn shell (/bin/KSh), Bourne again shell (/bin/bash), tenex C shell (tcsh )... And other shells. In Unix/Linux, the shell is independent of the core program, making it like an ordinary application, you can modify, update, or add new features without affecting the operating system.
Shell Activation
When the system starts, the core program is loaded with memory to manage the system until the system is closed. It establishes and controls processing programs, manages memory, file systems, communications, and so on. Other programs, including Shell programs, are stored on disks. Core Programs load them into memory, execute them, and clean up the system after they are aborted. Shell is a utility that starts when you check in. By interpreting commands entered by users (by command columns or command files), shell provides the ability for users to communicate with core programs.
When you sign in (LOGIN), an interactive shell starts and prompts you to enter the command. After you type a command, it is followed by Shell's work. It will:
1. syntax analysis command Column
2. Wildcards, redirection, pipeline, and job control)
3. Search for and execute commands
When you first learn Unix/Linux systems, most of your time is spent executing commands under the prompt.
Shell script is just like *. BAT in windows.
If you often enter a group of commands in the same form, you may want to automatically execute those tasks. In this way, you can put some commands into a file (called a command file or shell script) and then execute the file. A shell command file is like a batch of commands under DOS (such as autoexec. BAT): It stores a series of Unix commands into a file and then executes the file. Mature command files also support control structures of several modern programming languages, such as conditional judgment, loops, file testing, and transfer parameters. To write a command file, you must not only learn the structure and skills of program design, but also have a deep understanding of Unix/Linux utilities and how they work. Some utilities are very powerful (such as grep, sed, and awk) and are often used in command files to manipulate command output and files. After you become familiar with those tools and program design structures, you can start to write command files. When the command is executed by the command file, you have used shell as the program language.
Shell Development History
First, it is important that the standard UNIX shell is V7 (at&t's seventh edition) UNIX, which was proposed at the end of 1979 and named after its creator Stephen Bourne. The Bourne shell is designed based on the language Algol and is mainly used for automated system management. While Bourne shell is popular for simplicity and speed, it lacks many conversational usage features, such as history, alias, and work control.
C shell was developed in the late 1970s s at the University of California, berkelai, and is released in part of 2bsd UNIX. This shell is mainly written by Bill Joy and provides some additional features that are invisible to the standard Bourne shell. C shell is based on the C program language and is used to share similar syntaxes when the program language is used. It also provides improvements in interactive application, such as command column history, alias, and work control. Because c shell is designed on a large machine and some additional functions are added, C shell runs slowly on a small machine, even on large machines, it seems slower than the Bourne shell.
With the Bourne shell and C shell, Unix users have a choice and it is better to argue that shell. At&t's David Korn invented the Korn shell in the middle of 1980s. It was released in 1986 and became part of the official svr4 UNIX in 1988. The Korn shell is actually a superset of The Bourne shell. It can be executed not only on Unix systems, but also on OS/2, VMS, and DOS. It provides upward compatibility with the Bourne shell, and adds many popular features on the C shell, increasing the speed and efficiency. The Korn shell has undergone many revisions. To find the version you are using, press Ctrl-V under the KSh symbol.
Three main Shells and their branches
In most Unix systems, the three well-known and widely supported shells are Bourne shell (at&t shell, bash in Linux) and c shell (Berkeley shell, tcsh in Linux) and Korn shell (the superset of The Bourne shell ). The three shells in the interactive mode behave similarly, but as a command file language, the syntax and execution efficiency are somewhat different.
The Bourne shell is a standard UNIX shell, which was often used as a management system. Most of the system management command files, such as RC start, stop, and shutdown, are the Bourne shell command files, and in single user mode) it is often used by system administrators when checked in as root. The Bourne shell is developed by at&t and is famous for its simplicity and speed. The default value of the Bourne shell prompt symbol is $.
C shell is developed by Berkeley and has added some new features, such as command history and alias (alias), built-in arithmetic, filename completion, and job control ). For users who often execute shell in conversation mode, they prefer to use C shell, but for system managers, they prefer to use Bourne shell as command files, this is because the kernel of the Bourne shell command is simpler and faster than the C shell command file. The default value of the C shell prompt symbol is %.
Korn shell is a superset of The Bourne shell, developed by David Korn of at&t. It adds some features and is more advanced than C shell. Features of the Korn shell include editable history, alias, function, regular expression wildcard, built-in arithmetic, Job control, and Coprocessing) and special debugging functions. The Bourne shell is almost fully compatible with the Korn shell (upward compatible), so programs developed under the Bourne shell can still be executed on the Korn shell. The default value of the Korn shell prompt symbol is $. In Linux, The Korn shell is called pdksh, which refers to the public domain Korn shell.
In addition to poor execution efficiency, the Korn shell is better in many aspects than the Bourne shell. However, it is difficult to compare the Korn shell with the c shell because both have their own strengths in many aspects, in terms of efficiency and ease of use, the Korn shell is superior to the C shell. I believe many users have a negative impression on the execution efficiency of the C shell.
In terms of shell syntax, the Korn shell is close to the general programming language, and it has subprograms and provides more types of data. As for the Bourne shell, it has the least Data Types among the three shells and only provides string variables and Boolean types. In the overall consideration, the Korn shell is the performer among the three, followed by the C shell, and finally the Bourne shell. However, there are still other factors to consider in actual use, for example, speed is the most important choice, and it is likely to adopt the Bourne shell, because it is the most basic shell and the fastest execution speed.
Functions of Shell
To ensure that the command entered under any prompt symbol can be properly executed. Shell has the following roles:
1. Read the input and syntax analysis command Columns
2. Evaluate special characters
3. Establish pipelines, redirection, and background handling
4. processing signals
5. Set up a program for execution