[Pick Up] a charming SHELL shell/Linux | SHELL script getting started, shelllinux

Source: Internet
Author: User
Tags microsoft windows 10

[Pick Up] a charming SHELL shell/Linux | SHELL script getting started, shelllinux
Adhere to knowledge sharing, this article prepared by Alopex, reprinted please indicate Source Address: http://www.cnblogs.com/alopex/ index:

  • What is shell?
  • Shell Classification
  • Shell script execution Method
Abstract:
  • What is the essence of shell?
  • In addition to the bash shell, which shells are there?
  • How to execute shell scripts and shell scripts

 

What is shell?Generally, the operating system consists of User Interface and kernel. the kernel is the core of the operating system, it is the soul of an operating system. The main functions of the kernel include the following:
  • In brief, the kernel is responsible for managing the use of computer hardware resources (CPU, memory, hard disk, peripheral device I/O ).
The kernel is so important that it plays a vital role in the stable and efficient operation of the system. therefore, the operating system does not allow users to directly interact with the kernel. It (OS) allows users to access the operating system in another way, called the user interface (UI) in early computers used to interact with users, the operating system only had the command-line interface (command-line interface) for short, CLI. In English words, shell is translated into [SHELL], which indicates that shell is used to describe the command line interface with SHELL to protect the soft part inside, this "trendy" statement was first created in Multics (1964-1965) by Louis Pouzin, one of the developers, about the origin of SHELL, click here for more http://www.multicians.org/shell.html thanks Louis Pouzin for giving the CLI a vivid name :)
  • In a simple summary, the essence of shell should be CLI, which is an interface for users to interact with the system through command lines.
Shell ClassificationOperating System: CentOS release 6.9 (Final) command prompt PS1: \ [\ e [31m \]> \ [\ e [m \] (in red> is the command prompt) before introducing the shell classification, let's first introduce several common shell operations, view the system's default shell, view the shell in the system, and view the bash version.

In September 2014, bash exposed a serious vulnerability CVE-2014-6271

ShellShock Bug (specially crafted Environment Variable Injection Attack) we use the following command to test the system env x = '(){:;}; echo vulnerable 'bash-c "echo this is a test" if the test result only shows "this is a test", your system is normal, otherwise, you need to patch bash (the following only applies to CentOS/redhat)

 

There are two types of Linux shell: Bourne shell and C shell. First, we will introduce three major members of the Bourne shell family: [sh, ksh, bash] [SH] sh its developer is Stephen Bourne. in V7 Unix, it replaces the previously used Thompson shell as the default shell. It is interesting that many of the features of sh settings are still used till now.

Features of the Bourne shell versions since 1979 include:

  • Built-intestCommand-System III shell (1981)
  • # As comment character-System III shells (1981)
  • Colon in parameter substitutions "$ {parameter: = word}"-System III shell (1981)
  • continueWith argument-System III shell (1981)
  • cat <<-EOFFor indented here documents-System III shell (1981)
  • Functions andreturnBuiltin-SVR2 shell (1984)
  • Built-insunset,echo,type-SVR2 shell (1984)
  • Source code de-ALGOL68-ized-SVR2 shell (1984)
  • Modern"$@"-SVR3 shell (1986)
  • Built-ingetopts-SVR3 shells (1986)
  • Cleaned up parameter handling allows recursively callable functions-SVR3 shell (1986)
  • 8-bit clean-SVR3 shell (1986)
  • Job control-SVR4 shell (0, 1989)
  • Multi-byte support-SVR4 shells (1989)
[Ksh] Ksh is short for KornShell. Its developer is David Korn. It was initially developed based on the Bourne shell. Therefore, compared with sh in the Bourne shell array, Ksh has the following features:
  • Job control, command aliasing, and command history designed after the corresponding C shell features. Job control was added to the Bourne Shell in 1989.
  • A choice of three command line editing styles based on vi, Emacs, and XEmacs.
  • Associative arrays and built-in floating point arithmeticoperations (only available in the ksh93 version of KornShell ).
  • Dynamic extensibility of built-in commands (as of ksh93)
[Bash] bash is the full name of Bourne-again shell. It is developed by Brian Fox of the GUN program to replace the Bourne shell. It is a variety of Linux releases and apple (first OSX) the default shell is supported by Microsoft Windows 10. Although bash is a substitute for sh, bash is not fully compatible with sh. in CentOS 6.9, sh is a connection file connected to bash. Therefore, the effect of using sh and bash commands is the same.

 

The C Shell family has two members: [csh, tcsh]

[Csh] csh was designed by Bill Joy because csh has interactive features. In 1980, csh was easy to use, the design concept that won the favor of csh is to make it more open like C language and have better user interaction.

Bourne shell

#!/bin/shif [ $days -gt 365 ]then   echo This is over a year.fi
 

C shell

#! /Bin/cshif ($ days> 365) then echo This is over a year. endif
The above example demonstrates the difference between csh and bash in script writing. For the above scripts, csh is slightly more readable [tcsh] Because sh has an advanced version of bash, csh also has its advanced version, which is called tcsh. It is a BSD-related system. tcsh is a simple arrangement. shell has two large arrays: Bourne shell and C shellBourne shell (sh) --> Korn shell (ksh) Bourne shell (sh) --> Bourne again shell (bash) the most popular shell csh on multiple Linux distributions --> tcsh is now the most popular shell on the BSD system Shell script execution Method

 

# Run the script [the first method is sh script. sh] This is a very common shell script execution method. because it does not require the user to grant the script execution permission. sh command to receive the script. sh file as input parameter, enable a sub-shell for Command Parsing and execution [second method: source (.) script. sh] in this way, you do not need to grant the script execution permission. The script will be executed directly in the current shell, which means that in the script. the variables or functions defined in sh are retained after the script is executed ,". "script. sh. sh can be executed in both bash and csh shell.) [method 3. /script. sh] in this way, you must grant the script execution permission (chmod a + x script. sh) to run the script. The sub-shell is used to parse and execute the command.
[About the child shell and the parent shell] In simple terms, the relationship between the child shell and the parent shell has two points: 1. the sub-shell will copy the variables and functions of the parent shell, just as the child inherits the genes of the parent, 2. only the sub-shell knows the variables and functions set in the sub-shell. The sub-shell cannot change the variables and function scripts set by the parent shell during execution. If source /. method to execute the script. The command will be parsed and executed in the current shell. Use a simple script to execute the script in the current shell, and the sub-shell to execute the script to get the content of this script after using the current shell to execute the cd command, the current shell directory has changed after using the sub-shell to execute the cd command, the current shell directory has not changed ---------------------------------- reference: https://www.amazon.com/Computer-Science-Overview-Glenn -Brookshear/dp/0133760065 // Computer Science: An Overview (12th Edition) https://www.wikiwand.com/en/Kernel_ (operating_system) // Kernel (operating system) http://www.multicians.org/shell.html // The Origin of the Shell https://www.wikiwand.com/en/Command-line_interface// Command-line interface https://unix.stackexchange.com/questions/14934/why-was-the-word-shell-used-to-descibe-a-command-line-in Terface // Why was the word "shell" used to descibe a command-line interface? Https://access.redhat.com/blogs/766093/posts/1976383 // Bash specially-crafted environment variables code injection attack https://www.youtube.com/watch? V = hlDxOvO4Jxk // What is the ShellShock Bug? (September 2014) https://www.youtube.com/watch? V = UllSNdgGLbo // ShellShock Attack Demonstration stration https://www.wikiwand.com/en/Bourne_shell // Bourne shell https://www.wikiwand.com/en/KornShell // KornShellhttps: // www.wikiwand.com/en/Bash_ (Unix_shell) // Bash (Unix shell) https://www.wikiwand.com/en/C_shell // C shell https://www.wikiwand.com/en/Tcsh // tcsh https://unix.stackexchange.com/questions/2976/different-ways-to-execute-a-shell-script // Different ways to execute a shell script

Related Article

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.