One, the main use of the Bash Shell in Linux; View the supported shell types available on Linux systems :
Vim/etc/shell
The way to perform shel footsteps:
1. Give footsteps the ability to execute permissions and invoke the script using a relative or absolute path
chmod 755 Test. SH #赋予该脚本可执行权限. /test. SH #以相对路径执行该命令~/test. SH #一绝对路径执行该命令
2. Invoke the script with the shell command (the script may not need to execute permissions at this time):
bash test.js #使用bash Shell executes sh test.js #使用sh执行
Note: The shell script is #! /bin/bash begins by saying that the shell script is written (equivalent to PHP's <?php?>)
Second, the Shell History Command view
Run: History to see the commands that have been used under the user (through the up and down arrows to see the previous or next command executed)
Use Vim ~/.bash_history to view historical commands that have been maintained
You can view the maximum number of saved history entries by viewing the/etc/profile
By:!n the nth command of the repeatable history record
By:!str can repeat the last history command starting with Str
C. Shell definition aliases
The aliasls"ls-l" #定义ls-L is named LS, and is actually executed when LS is executed ls-l
Configuration of aliases (configuration aliases are permanently active):
Edit ~/.BASHRC
Iv. output Redirection
Standard output/dev/stdin 0 keyboard
Standard output/dev/stdout 1 display
Standard error Output/dev/strerr 2 display
ls > AA cover to AA
LS >> AA append to AA
LS hahah 2>aa output error to AA (no spaces on both sides of the error output)
LS &> AA will output correct and error to AA
V. Execution of multiple orders
ls Date #中断中输入后会顺序执行该3条命令 ls Date #前一条正确执行后, execute LS AAA on the following line | | Date #前一条命令错误执行, the next command executes the lsechoecho no #ls AAA correctly executes output Yes, executes error output nolsgrep etc #前一条命令的执行结果 as the execution condition of the latter command
Vi. variables
1. Variable classification
- Local variables
- Environment variables
- Positional parameter variables
- Pre-defined variables
Environment variable configuration file:
/etc/profile
/etc/bashrc
~/.bashrc
~/.bash_profile
The first two take effect for all users, and the latter two for the specified user
Shell Simple Usage Notes