Understand what a shell is in 1 minute

Speaking of what is a shell?

Shell is an "interface used to talk to the operating system" and an "environment" for controlling commands and the like.
Insert picture description here
Let them think that the shell covering the Linux core kernel in this form is the shell, which is easy to understand.
Without this shell, even if you log in, nothing will be displayed or you will return to the login screen. In other words, almost nothing can be done. I think the shell, the kernel, and the terminal are becoming more and more difficult to understand. This is a relationship, as shown in the figure below.
Insert picture description here
A shell can accept commands and interact with the operating system. In the CUI environment, the shell is the most familiar interface. The current common shell in Linux is "bash".

Shell scripting and Unix philosophy

In the "Unix Philosophy",

  • Connect a small command with a pipe, etc. to make the command work like a filter.
  • Basically, the output is plain text. Considering portability, shell scripts are used.
    There is such a philosophy. Because Unix was originally regarded as a very small thing.

Linux also has many things in common with Unix philosophy. In fact, even if you only use pipes and redirection, you can achieve a variety of things, but shell scripts can achieve more advanced things with further control.

Shell scripting is a kind of programming

Shell script can be said to be "a script that the shell can explain". More simply, it can be thought of as a document, allowing commands to be executed side by side. For example, even the following content can be fully used as a shell script.

echo 'shell'
echo 'script'
echo 'test'

Just let it display a string, but this is also enough for a shell script. In addition, it can also be programmed. The Linux shell can have control structures such as variables, branches, and repetitions.

In addition, the shell script is recorded in the text. If there is the same shell and command running environment, it can be run no matter where it is placed, so it has very convenient portability.

This is a feeling of assembling building blocks

Some people may cause rejection as soon as they hear programming. However, shell scripting is not difficult at all. It can be said that compared with memorizing other programming languages, there is almost no difficulty. More frankly, things like very complicated things are best not to be written in shell scripts. This is basically a means of arranging and controlling commands and automating work. If it is a metaphor, it is a means of "stacking commands on top of each other like building blocks."

These commands are sometimes switched through "conditional branching", or control such as executing loops through "repetition". Although I am not unaware of algorithms and data structures, it is overwhelmingly easy compared to the C language and Java language that are system description languages. First of all, because fine algorithms and so on are absorbed at the command level, even if you don't know the content, as long as you know the results of input and output, there are often ways to do it.

Guess you like

Origin blog.csdn.net/qq_18191333/article/details/107534035