What is a shell?
Shell
Is the user interface of the system, which provides an interface between the user and the kernel for interactive operation. At the same time, the shell is a command interpreter that interprets the commands entered by the user and sends them to the kernel. Not only this,Shell
Has its own programming language for editing commands, which allows the user to write theshell
command to form a program.
It is not the various terminal emulators of different distributions that often make a difference in the actual experience in the graphical interface, but thisShell
(shell). There's a shell and a nucleus, and the nucleus here meansUNIX/Linux
KernelShell
Refers to the Software (command parser) that "provides the user with an interface", similar toDOS
Under thecommand
(command line) and latercmd.exe
。
UNIX/Linux
Under the operating systemShell
It is the interface of user interaction and the scripting language of control system. Of course, this is different fromWindows
The command line, although it also provides a very simple control statement. InWindows
Operating system, some users will never directly use theShell
。 However inUNIX
Series of operating systems,Shell
is still a scripting interpreter that controls system startup and many other utilities.
Shell category
in unix/linux
In the more common shell
Bourne Again Shell
(Bash for short)
Bourne Shell
(referred to as SH)
C-Shell
(abbreviation CSH)
Korn Shell
(Abbreviation Ksh)
Z shell
(abbreviation zsh)
Ubuntu
The terminal is using the defaultbash
, the default desktop environment isGNOME
OrUnity
(based on GNOME), our environment uses thezsh
Andxfce
。
can also through cat/etc/shells
To see the shell types on our host.
First shell script
Open a text editor (you can usevi/vim
command to create a file), creating a new filetest.sh
, the extension is sh (sh for Shell), and the extension does not affect script execution.
Enter the code:
esc
Key, and then enter :wq
Save exit Edit, specific vim editor
is explained in more detail in later chapters.
Note: #!
This is a convention tag that tells the system that the script is executed with the specified interpreter. When not specified, $SHELL
the value of the variable is used by default.
An attempt is performed to script the script file that is written./test.sh direct execution prompts for insufficient script permissions.
Use chmod +x test.sh to give execute permissions to scripts written
Give the script file permission to execute once again./test.sh, output script content after execution
In practical work it is recommended to use ZSH to execute the script, he can provide a lot of script output information.
Introduction to Linux shell