Linux Shell Execution principle

Source: Internet
Author: User

Shell Introduction

The shell is the user interface of the system and provides an interface for users to interoperate with the kernel. It receives the command entered by the user and feeds it into the kernel to execute.

Running background

A basic Linux system architecture

B. As can be seen, the shell is at the middle level in the system. He provides a way for users and kernel to interact with the program.

C. A number of advantages with regard to hierarchies:

1, the developer can only focus on the entire structure of one of the layers;
2, can easily use the new implementation to replace the original level of implementation;
3. Can reduce the dependence between layer and layer;
4, in favor of standardization;
5, facilitate the reuse of the logic of each layer.

Disadvantages:

1, reduce the performance of the system.

2. Sometimes cascade changes are caused

Shell command Execution principle

Surface understanding of our general practice is: Open the terminal, enter the command, hit enter, wait for the command to run , to get results

So, the process of detailed analysis, and what is included?

Open terminal, enter command, hit enter----IO interrupt

Wait process:

Shell parsing commands and parameters----shell (an explanatory program for an end location)

Fork copy near PCB related resources, prepare for command execution----system call

EXEC executes commands in the sub-process that the fork gets

Execution complete, return result----stack protection, stack frame Note: When executing commands such as LS &

The & symbol indicates that the command executes in the background, and when the command is executed, we cannot just enter the command, because the parent process executes the wait-wait child process while the fork executes the shell command, unless the user actively CTRL + C aborts the command execution or CTRL + Z is placed in the background execution.

Reference http://my.oschina.net/u/866271/blog/232840

Linux Shell Execution principle

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.