preface
As a young man who just started working, Linux is really important after a period of internship. Being proficient with Linux is not only more productive, it’s also cool. So decided to systematically learn Linux…
Shell: The coat of Linux
Those of you who have used Linux have probably heard of shells at some point, but we don’t necessarily have a clear understanding of them.
1.1 Shell Definition
A Shell is an application, a program with a special function: it provides an interface for the user to interact with the kernel. An application is a heap of binary files on a hard disk. Executing an application is equivalent to executing code in binary files. What is the kernel? I’ll talk about that later. Interoperations are the commands we type in Linux to make Linux do things, such as:
Enter ls to display the files/directories in the current directory# user @ user-computer in ~ [11:31:09]
$ ls
Desktop Downloads Movies OpenSource Public project
Documents Library Music Pictures maven sh
Copy the code
A Shell is an application that allows you to talk to the Linux operating system. After the user login Linux system, it will call into the system memory execution, it can be the user input command into the computer can understand the mechanical code to the kernel execution.
1.2 A brief introduction to the Shell
From my previous description, we should know what a Shell is. Just as there are many chat tools, there are more than one Shell application in Linux. Check out the current Linux shells by running the cat /etc/shells command:
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
Copy the code
Bash scripts are very powerful and can save a lot of time, especially when dealing with automatic loops or large tasks. Bash is a built-in Shell for many Linux platforms. I use the ZSH, because it set a lot of easy to use plug-ins, similar to git simple command, code automatic completion of what, more suitable for me this command can not remember the weak chicken ~. Command to switch the Linux default Shell: CHSH -s /bin/shell name.
Shell is a scripting language that uses interpretive execution, so it has some advantages over the interpretive type:
- The syntax and structure are usually simple
- It’s easy to learn and use
- Don’t need to compile
- Application development productivity is better than performance
- .
As for the Shell operation, the principle of the simple here will not say (in fact, I do not ~). We just talked about how to communicate with Linux, but we don’t know how Linux actually understands and processes these commands. Next, I will explain my understanding of Linux kernel through QQ startup to sending messages. The following content, learning summary time – “interesting Linux operating system”, a very good column, recommended to buy learning!
Kernel: the heart of Linux
Like the relationship between man and heart, the Linux kernel is not an operating system; it is part of a complete system. The Linux kernel controls the basic hardware of the Linux operating system and has many functions, such as file management, memory, multithreading, network and so on.
Below we open QQ this example to tell about some operation relations in Linux kernel.
1 ⃣️ Device subsystem
A device subsystem is a system that manages system devices. Like mouse, keyboard is the input device, graphics card, display is the output device. When the mouse moves, it will move the corresponding distance on the display according to the mouse sensitivity. Typing the character ‘a’ on the keyboard will display the character ‘a’ in the focus target.
We can use the existing equipment, mobile search QQ this application, click run.
2 ⃣️ File subsystem
Before it runs, we will definitely go to the official website of Tencent to download QQ. It will remind you of the directory when you download it and the installation path when you install it. Once installed, the application files are stored on your hard drive. But the storage size of the hard disk is fixed, certainly not because I installed a QQ storage is not enough to cover the code I just wrote yesterday… So you need a file system to manage file storage.
3 ⃣ ️Process management system
After INSTALLING QQ, let’s open it. As mentioned earlier, applications are stored on hard disk in binary format. When the operating system gets the binary execution file of QQ, it can run this file. The binary files of QQ are static, called programs, while the QQ running is continuous, called processes.
Processes cannot be manipulated arbitrarily and need to be scheduled by Linux. For any program to run, it needs to make system calls and create processes. The execution of the Process also needs to allocate the CPU to execute, i.e. execute according to the binary code in the program, so we need a Process Management Subsystem to manage the Process. Sometimes the application is too open and feels sluggish, probably because the CPU has not been able to execute the process code.
4 ⃣ ️Memory management subsystem
The process generates some data as it executes, just as you generate chat logs when you chat. The data may be classified and you don’t want anyone else to see it or have it changed. For example, if you write a 1W word article on your blog and switch to QQ, the previous one will disappear, which is unbearable to anyone. Therefore, in the operating system, different processes have different memory space, but the entire computer memory is only so little, so it needs unified management and allocation. That’s where the Memory Management Subsystem is needed.
5 ⃣️ Network subsystem
When you chat with others on QQ, you send short messages and need to send network requests. Linux manages the sending and receiving of these requests through the ️ network subsystem.
Summary and Reference
I have talked about the relationship between Linux and Shell and the general role of the component system of the Linux kernel. Beginner learn Linux, there are mistakes or optimization of the place thank you see officer correction 🙏. The article refers to:
- “Linux Shell Programming from Beginner to Master”
- Geek Time – Interesting Linux Systems – Chapter 3