Linux Learning Path-shell working principle

Source: Internet
Author: User

Shell Working principle

What is a shell?

The shell is a general term for command Language, command interpreter and programming language, which is an interface between the user and the Linux kernel, and provides the user with an interface to use the operating system.

Shell the characteristics

Shell An important feature of this is that it is itself an interpreted programming language that is run by the interpreter throughout the process, one line at a time and one row per run. the Shell programming language supports most of the program elements that can be seen in high-level languages, such as functions, variables, arrays, and program control structures. the Shell programming language is easy to learn, and any command that can be typed at the prompt can be placed into an executable Shell program.

Shell How the command parsing is performed

(1) reads the command line that the user entered by the keyboard.

(2) parse the command with the command name as the file name, and transform the other parameters into the form required by the system call EXECVE () internal processing.

(3) The terminal process calls fork () to establish a child process.

(4) The terminal process itself uses the system call WAIT4 () to wait for the child process to complete (not wait if it is a background command). When the child process is run, call Execve (), and the child process looks for the file (which is a file of the command interpreter) to the directory based on the file name (i.e., the command name), and calls it into memory to execute the program (explaining the command).

(5) if there is a & (Background command symbol) at the end of the command, the terminal process does not have to wait for the system call WAIT4 (), immediately prompts the user to enter the next command, and then goes to ⑴. If there is no & at the end of the command, the terminal process waits until the child process (that is, the process running the command) finishes processing, reports to the parent process (the terminal process), and when the terminal process wakes up, after making the necessary discrimination, the terminal process prompts the user to enter a new command to repeat the process.


Shell Basic execution process and the relationship between parent and child processes:

650) this.width=650; "title=" 1.gif "src=" Http://s3.51cto.com/wyfs02/M02/73/88/wKiom1YAt0uC2keAAABnSMUjelg120.gif " alt= "Wkiom1yat0uc2keaaabnsmujelg120.gif"/>

Shell How to start

Shell start After you have successfully logged into the system and always act as a means of interacting with the system kernel until you exit the system. Each user on your system has a default shell. The default shell for each user is specified in the/etc/passwd file in the system.

Shell Types of

Bash

Bash Shell is a free version of the Bourne shell, which is the oldest Unix shell, including many additional features. Bash has an editable command line that can be checked back to the history command, enabling tab completion to prevent users from entering long file names.

Csh

C Shell using the "Class C" syntax, many of the features of the Bourne shell are borrowed, but the internal shell command set differs.

Ksh

Korn Shell The syntax is the same as the Bourne shell, with the easy-to- use features of the C shell. Many of the installation scripts use Ksh, and you should install it on your system even if you do not take it as your primary shell.

Tcsh

TC Shell is an enhanced version of the C shell and is fully compatible with the C shell.

Zsh

Z Shell is an enhanced version of the Korn shell with many features of the bash shell.

This article is from the "naïve Little Comrade" blog, please be sure to keep this source http://dengxi.blog.51cto.com/4804263/1696978

Linux Learning Path-shell working principle

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.