The opening is introduced
Linux is a very useful feature, this feature is called Shell script.
Shell scripts also play a very important role in my daily development work. We can use Shell scripts to complete some simple tasks in the project, such as periodically deleting log files scripts, one-click deployment system scripts and other automatic functions.
Therefore, mastering Shell scripting and dealing with some tedious things in automation will get twice the result with half the effort. It is essential for Linux developers and operations personnel to master Shell programming.
What is a Shell?
The Shell is a command interpreter used to explain user operations on the operating system.
Simply put, the Shell translates the commands executed by the user to the Linux kernel, and the Linux kernel returns the results of the command execution to the user.
For example, the Linux ls command to view a list of files
[root@lincoding /]# ls
bin dev home lib64 media opt root selinux sys usr
boot etc lib lost+found mnt proc sbin srv tmp var
Copy the code
The process of ls execution is briefly summarized as follows:
We can control the kernel and the operating system with simple commands, and do a lot of things we want to do. Beginner users don’t need to know the basic knowledge of Linux, so this is the main function of the Shell interpreter.
You can check the shells supported by your Linux system by using cat /etc/shells. My Linux version is CentOs6.5, which supports the following shells:
[root@lincoding /]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
Copy the code
The common and default Shell for Linux CentoO6.5 is bash, so we just need to relearn bash first.
summary
This chapter briefly introduces the basic concepts of Shell:
-
The function of the Shell is to interpret the Linux commands entered by the user to the kernel. The kernel will return the execution result of the command to the Shell, and the Shell will display it to the user.
-
There are many types of Shell, and the default Shell varies from system to system. CentOs6.5’s default Shell interpreter is bash.