In Linux, if you don’t know what Bash is, then I can only say: don’t learn anything else. Bash is an important foundation for almost all command-line formats and future mainframe maintenance and management. Come on old iron!! ** xiao er, serve hard dishes to guests!! 支那

Hardware, kernel and Shell

As long as there are some basic computer people know, the management of computer hardware is the operating system Kernel (Kernel), this Kernel needs to be protected, why need to protect? Because the operating system is actually a collection of some software, because this group of software is in control of the entire hardware and management system activity detection, so it is not ordinary people can touch, how to touch broken? Just like your little girlfriend, she calls the shots and you have the responsibility to protect her. Since the kernel is protected, we need a medium to communicate with it. At this time, we ordinary users can only communicate with the kernel through the shell, so that the kernel can accomplish our tasks.

So, for example, everyone listens to music on a computer, right, so what does it take for a computer to play a song? One is hardware, that is, sound cards, speakers and other equipment; The second is the kernel of the operating system, which can support the chipset, while providing the driver of the chip; The third is the application, which is simple and can be understood as user input commands that emit sound. Now the question is how does the system recognize your command, how does the hardware know it needs to execute your command? At this point, we need to use the Shell to input commands to communicate with the kernel, so that the kernel can control the hardware to play the music accurately. Now you know why there are applications, because people have to use them anyway, and it is impossible for everyone to have direct access to the system, so applications are developed, and the masses of users can use the application to call the kernel to complete the hardware tasks we need.

2. Check the Shell you are using

Let’s get to a more esoteric question, which Shell does Linux use? What? What kind of? Isn’t that one? I’m confused, too. Ha ha, don’t worry, LET me tell you something. In the early years, long, long ago, the UNIX era, there was a lot of development, so there were many different versions of Shell developers, such as C Shell,Bourne Shell, K Shell, etc., The Shell used for Linux is the Bourne Again Shell(bash), which is an upgrade of the Bourne Shell. If you want to know what shells your Linux supports, here’s a solution: go into your system and check the file /etc/shellsAbove is the output from my system. It is important to note that /bin/sh has been replaced by /bin/bash. And what if you want to know what shell your user is using by default? Again, in /etc/passwd, enter cat /passwd, and the last data in each line of the output is the default shell that you can use when you log in. There is a “weird” Shell

Iii. Functions of Shell

1) Store the history command: it can record the command used, because you only need to press [up and down] can call up the command used before, do not have to repeatedly knock, is not very cool, otherwise encounter that kind of long command, you will go to suicide. In this function, the default entries can be up to 1000, almost all the commands you use in this use, isn’t it amazing? Is it necessary to ask again where the record of this command is stored? The.bash_history file is stored in your home directory. It is important to note that the executed commands are stored in this file only after logging out at the end of this login, and are temporarily stored in memory for operations that have not been logged out. Here is some of the information I found in this file in my home directory.But one thing is important, because if a hacker gets into this file, he can see the commands in this file, and there are commands related to your system, and you’re in trouble. So it’s not clear whether it’s better to have more commands in this file or fewer.

2) Command and file supplement function [Tab] : The first word of a string of commands is followed by command completion [Tab] : the second word of a string of commands is followed by file completion

3) Alias setting function Use the alias command to alias a command for easy use

For example, I want to know how many files start with x under /usr/bin

5) Programmatic scripts (extremely important)

I won’t go into detail about the script, there will be a lot of explanation later

So much for the basic knowledge of the shell, the next article will explain the variable function of the shell, if you want to know how to do it, please listen to the decomposition of next