Introduction to basic Shell knowledge in Linux (1)

Source: Internet
Author: User

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 executed through command) or program). The program has a compiler) to convert the program into binary code. But what about the command? 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, while C shell/bin/csh in UNIX can be used in addition to the Bourne shell/bin/sh), Korn shell/bin/ksh), Bourne again shell/bin/bash), Tenex C shelltcsh )... 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 the commands entered by the user by the command column or command file), Shell provides the user and core program to generate a conversation function.
When you check 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. process the characters wildcards), switch to redirection, pipeline pipes) and work control job control)
3. Search for and execute commands
When you start to learn UNIX/Linux systems, most of your time will be spent in prompt.
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, script), and then execute this 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. They are often used in command files.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 the seventh version of V7AT & T. UNIX 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 shellAT & T shell, BASH in Linux), C shellBerkeley shell, and TCSH in Linux) and Korn shellBourne shell ). The three shells are similar in the interactive mode, 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 command files of the Bourne shell and are in the single user mode.It is often used by system administrators when checked in as root in single user mode. 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 of the University of Berkeley. It has added some new features, such as command column history (history) and alias), built-in arithmetic, and 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 the superset of The Bourne shell. It is developed by David Korn of AT&T. It adds some features and is more advanced than C shell. Korn shell features editable history, alias, function, regular expression, regular expression wildcard), built-in arithmetic, job control), coprocessing) and special debugging functions. The Bourne shell is almost fully compatible with the Korn shell upward compatible), so programs developed in 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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.