Shell interpreter (learning note 4) and shell interpreter
I. Shell interpreter
Shell interpreter, a bridge between the user and the operating system kernel
Shell is between the operating system kernel and the user. It is responsible for receiving the operation commands (commands) entered by the user, running and interpreting the commands, passing the operations to the operating system kernel and executing
The shell program acts as a "command interpreter" in the system.
For example, cmd.exe in Windows is similar to this role, but it receives the DOS command.
Ii. shell in Linux
2.1 common Shell types
- Bsh: Written by Bell Labs. Bsh is an earlier UNIX Shell program that implements the most basic command interpreter function and can also be used as a script programming language.
- Csh: It is named after the syntax style of C language. It has made many improvements on the user's command line interactive interface and added features such as history, alias, file name replacement, and job enumeration, compared with Bsh, Csh is more suitable for providing command interaction operations for users.
- Ksh: After Bsh and Csh, it combines the functional advantages of both, and has the Bsh syntax and Csh interaction features.
- Bash: It can be seen from the name that it is an upgraded version of Bsh. It is a famous open-source software project. Currently, most Linux versions (including Red Hat's Linux systems) bash is used as the default Shell program. When a Shell program is run, the Bash program is actually run.
- Zsh: More Shell programs designed based on interactive operations, integrating the advantages of Bash, Ksh, and other Shell programs
Iii. Bash
3.1 Linux default Shell program
Command file location:/bin/bash File
[root@model /]# ls /bin/bash /bin/bash[root@model /]#
[root@model /]# ll /bin/bash -rwxr-xr-x. 1 root root 940416 Oct 16 21:56 /bin/bash[root@model /]#
3.2 main functions
- Command history:It is a function used in BaSh to improve the efficiency of command input. It allows users to repeat the commands that have already been input, reduce repetitive input, and move up the direction keys,
History can view the commands that have been entered
- Command alias:You can define frequently-used complex commands as short aliases. When you need to execute this complex command, you only need to use aliases to complete the corresponding operations, reducing and operating complexity, improved input efficiency
- Standard Input/Output and redirection:Linux uses files to describe system hardware, devices, and other resources.
- Pipeline Operation:In the Bash environment, a mechanism is provided for the coordination between different commands. The command output result on the left of the pipeline symbol is used as the command input on the right, multiple pipelines can exist in the same command line.
cat etc/inittab >>/tmp/bootype.txt
[root@model Documents]# cat >> a.txt << fw> fffffffffff> dddddddddd> fw[root@model Documents]#
Add the two fws to the a.txt file. If the.txt file does not exist, create the file.
4. Command Line
Command line format:
Command word [Option] [parameter]
Command: in short, all strings on the Linux character interface and character terminals that can name specific operations and tasks can be called "commands ". Commands only represent commands and program names that implement a certain type of functions. Command words are case sensitive and are the most important part of the entire command.
[Option]: Adjust the specific functions of a command to determine how the command will be executed. If the same command is used with different options, similar but slightly different functions can be obtained.
[Parameter]: The processing object of command words, including files, directories, folders, and users. The number of parameters can be 0 or more.
Command wordOption parameters are separated by spaces. Extra spaces are ignored.
The order of options and parameters can be confused. The order can be the opposite. This generally does not affect the normal execution of commands, except for special