There are two ways that Linux shell executes
Shell scripts start with #!/bin/bash, and the shell is executed with the first row checked and executed internally in the following ways:
$/bin/bash script.sh
1. Execute with SH.
$sh script.sh #脚本位于当前目录下
Or
$sh/home/path/script.sh #使用完整路径
2. Run the script independently.
You need to have executable permissions that can be set in the following way
$chmod a+x script.sh
Or
$chmod 755 script.sh
This can then be done in the following ways:
$./script.sh #./represents the current directory
Or
$/home/path/script.sh #使用完整路径
--------------------------------------------------------------------------------
Appendix: chmod Command
chmod [-CFVR] [--help] [--version] Mode file ...
chmod owner Group World FileName
4–read (R)
2–write (W)
1–execute (x)
7 = 4+2+1 (Read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (Read/execute)
4 = 4 (Read)
3 = 2+1 (Write/execute)
2 = 2 (write)
1 = 1 (execute)
+ indicates an increase in permissions,-represents a cancellation permission, = Represents a unique set of permissions