Introduction to Linux Shells

zhaozj2021-02-11  221

Introduction to Linux Shells

Skill administrator (2000-12-24 10:28) 〖Back〗 〖Forward〗

What is the shell? Shell is a program with special features that is an interface between the core program (Kernel) of the user and the UNIX / Linux operating system. Why do we say shell is a system of system core programs and users? Readers who have read the operating system know that the operating system is a managers and distributors of a system resource. When you have a demand, you have to propose to the system; from the perspective of the operating system, it must also prevent the user because What is wrong to cause a system damage? As we all know, the command is commanded under command (COMMAND) or program (Compiler) to convert the program into binary code, but what? In fact, shell is also a program, which is read by the input device, and then converts it to the computer to understand the machine code, and then execute it. Various operating systems have its own shell, with DOS as an example, its shell is a command.com file. Like DOS, there are different command interpretation programs such as NDOS, 4DOS, DRDOS, can replace standard Command.com. Unix has c shell (/ bin / csh), Korn Shell, etc. / BIN / KSH), Bourne Again Shell (/ Bash), Tenex C Shell (TCSH) ... and so on. Unix / Linux will independently, so that it is like a general application that can modify, update the version or add new features without affecting the operating system itself. When the SHELL activation is started in the system, the core program will be loaded, responsible for the management of the system until the system is closed. It establishes and controls handlers, manages memory, archive systems, communications, and more. And other programs, including the shell program, are stored in the disk. The core programs load themselves, execute them, and abort the system after they abort. 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), the shell provides the function of the user and the core program to generate a conversation. When you check in (login), a conversation shell will start with you and prompt you to enter the command. After you type a command, then the shell works, it will do: 1. Syntax Analysis Command Column 2. Processing the Wildcards, REDIRECTION, Pipeline (Pipes) and Work Control (Job Control) 3. Search and execute commands When you start working in a UNIX / Linux system, you will spend most of the time to execute a command. If you often enter a group of identical commands, you may want to automate those jobs. Thus, you can put some commands into a file (called command file, script) and then execute the file. A shell command file is like a batch file under DOS (such as autoexec.bat): It stores a series of UNIX commands into a file, then execute the file.

More mature command files also support the control structure of several modern programming languages, such as the conditional judgment, cycle, archive test, transmission parameters, etc. To write a write command, not only learn the structure and skills of the program design, but also have an in-depth understanding of UNIX / Linux utilities and how to operate. Some utilities are very powerful (for example, GREP, SED, and AWK), which are often used to command file output and files. After you become familiar with those tools and programming structures, you can start writing the command file. When you execute a command by the command file, you have already used the shell as a program language. The first thing that shell's life is, the standard UNIX shell is V7 (the 7th edition of AT & T) UNIX, which is proposed in the end of 1979 and is named with its creator Stephen Bourne. Bourne Shell is designed based on Algol language, mainly used to do automation system management. Although the Bourne Shell is popular with simple and speed, it lacks many of the characteristics of talkability, such as the history, alias and work control. C shell is a part of the 1970s in Berke in the University of California. This shell is mainly written by Bill Joy, providing some additional features that cannot be seen in the standard Bourne Shell. C shell is the foundation as a C program language and it is used to share similar syntax when the program language. It also provides improvements in conversation, such as command columns, alias, and work control. Because c shell is designed on a large machine and adds some additional functions, C shell runs slowly on a small machine, even if it is compared to the Bourne Shell even in a large machine. With Bourne Shell and C shell, UNIX users have selected and argued that the shell is better. At & T David Korn invented the Korn Shell in the mid-1980s, issued in 1986 and became formal SVR4 UNIX in 1988. The Korn Shell is actually a Bourne Shell's superchard and is not only executed on the UNIX system, and it can be performed on OS / 2, VMS, and DOS. It provides the ability to compatible with Bourne Shell and add a lot of popularity on C shell, adding speed and efficiency. The Korn Shell has passed many revised editions. To find what you are using, then press the CTRL-V key under the KSH prompt symbol. Three main shells with them in most UNIX systems, three famous and widely supported shells are Bourne Shell (AT & T shell, Bash under Linux), c shell (Berkeley Shell, TCSH under Linux) And Korn shell (super collection of Bourne Shell). These three shells are quite similar in the Interactive mode, but as a command file language, it is somewhat different in grammar and execution efficiency. Bourne Shell is a standard UNIX Shell that is often used as a management system.

Most of the system management command files, such as RC START, STOP and Shutdown are the command file of the Bourne Shell, and it is often used by the system administrator when Single User Mode is checked in a single user mode. Bourne Shell is developed by AT & T, is a simple, famous. The default value of the Bourne Shell prompt symbol is $. C shell is developed by Berkeley, and has added some new features such as History, alias, internal arithmetic, file name completion (Filename Completion), and work control ( Job Control). For users who often perform shells in the conversation mode, they love to use c shell; but for system managers, they are preferred by bourne shell, because bourne shell command file ratio c shell command file Simple and fast. The default value of the C shell prompt symbol is%. The Korn Shell is a Bourne Shell, which is developed by AT & T David Korn. It adds some features, more advanced than C shell. The features of the Korn Shell include editable history, alias, functions, regular expressions, internal arithmetic, Job Control, Coprocessing, and special divisions Map function. Bourne Shell is almost compatible with the Korn shell, so the program developed under the Bourne Shell can still be executed on the Korn Shell. The default value of the Korn shell prompt symbol is also $. The Korn shell used in the Linux system is called pdksh, which refers to the Public Domain Korn shell. In addition to the efficiency of the execution, the Korn Shell is better than Bourne Shell in many ways; however, if the Korn Shell is difficult than C shell, both of them have their own strengths, efficiency and easy In terms of use, the Korn Shell is better than C shell, I believe that many users have negative impressions for the execution efficiency of C shell. In the SHELL grammar, the Korn Shell is more close to the general program language, and it has the functionality of the subroutine and provides more information. As for the Bourne Shell, it has the data type of three shells, only string variables and Boolean states. The Korn shell is the best in the three people, followed by c shell, and finally the Bourne Shell, but there are still other factors that should be included in the actual use, such as the most important choice, It is likely that Bourne Shell should be used because it is the most basic shell, the speed is executed the fastest. TCSH is a free software in recent years (C shell under Linux is actually using TCSH), which although it is not a UNIX standard equipment, but you can download it from many places.

If you are a C shell's support, the author suggests try TCSH because you can use it as a c shell to use. If you are willing to spend a time to learn, you can also enjoy many of its new superior features, such as: 1. TCSH provides a command line editor. 2. Provide a full functionality of the command column. 3. Provide spelling correction. It can automatically detect and correct the commands of the command column or a single word. 4. Dangerous commands detect and remind the function to avoid you in an accidental command that is unforgettable of RM *. 5. Provide shortcuts for common commands (Shortcut). Bash is backward compatible and integrates a number of C shell and Korn shell. These functions actually c shell (of course, TCSH) has, but the Bourne Shell has not been supported in the past. The following author will introduce the six important improvements in Bash (detailed instructions): 1. Operating control (Job Contare): 1. Working Control. Bash supports the signal and instructions on the work, this chapter will be mentioned later. 2. Aliass (aliases). The alias command is used to build another name for a command, and its operation is like a macro, expanding the command it represents. Alias ​​does not replace the name of the command, it just gives the other name. 3. Command History. The Bash Shell joined the command history function provided by c shell, which recorded the command you performed recently in the History Toolbox. The command is numbered by 1, the default is 500. The History Toolbox is a short-term memory that records the commands you have recently performed. To see these commands, you can type HISTORY at the command column, so that you will display a list of recently executed commands and add numbers in front. These commands are called an event in technology. The event is described is a "command that has been executed) already taken. The event is numbered in accordance with the order of execution, the larger the number of incidents, the larger the number, which is identified by its number or command. The History Toolp allows you to refer to a previously happened event, put it on the command column and allow you to perform it. The simplest method is to use the up and down button to put a history event on your command; you don't need to use the History display list. Press the up key to put the last historical event on your command, and then place the next historical event. Press the down button to place the previous event on the command column. 4. Command Column Edit. The Bash Shell command is built-in and allows you to easily modify the command you entered before execution. If you spell the word when you enter a command, you don't need to re-enter the entire command, just correct the error before executing the command. This is especially suitable for commands using a lengthy path name as a command. The command column editing job is part of the Emacs editing command. You can move a character with Ctrl-f or right-click forward, ctrl-b or to the left mover one character. Ctrl-D or DEL key will remove the characters where the cursor is currently located. To add text, you only need to move the cursor to where you want to insert the text and type new characters. Whenever, you can press ENTER to execute commands. 5. Allow the user to keep the keys. 6. Provide a richer variable pattern, command and control structure to the shell.

转载请注明原文地址:https://www.9cbs.com/read-3500.html

New Post(0)